Posts: 112
Threads: 22
Joined: Apr 2011
Reputation:
0
--i <3 already knowing RBX.lua, i made this in a few seconds, and this is my first script
local deb = false
link(game.World.Button1.Collided, function(nope)
if nope.Name == "Body" and deb == false then
deb = true
game.World.Button1.Color = Color(0,255,0) --green
sleep(1)
dep = false
game.World.Button1.Color = Color(255,0,0) --red
end
end)
Posts: 5,683
Threads: 413
Joined: Aug 2012
Reputation:
0
Looks right to me... although you might want to start using [lua] tags.
Posts: 112
Threads: 22
Joined: Apr 2011
Reputation:
0
[lua]--i <3 already knowing RBX.lua, i made this in a few seconds, and this is my first script
local deb = false
link(game.World.Button1.Collided, function(nope)
if nope.Name == "Body" and deb == false then
deb = true
game.World.Button1.Color = Color(0,255,0) --green
sleep(1)
dep = false
game.World.Button1.Color = Color(255,0,0) --red
end
end)[/lua]
Posts: 2,141
Threads: 104
Joined: Dec 2010
Reputation:
0
08-13-2011, 01:56 AM
(This post was last modified: 08-13-2011, 02:01 AM by dap300.)
That's one big link statement, I don't think it's supposed to be like that.
Let me try.
[lua]local deb = false
function onCollide(hit)
if hit.Name == "Body" and deb == false then
deb = true
game.World.Button1.Color = Color(0,255,0) --green
sleep(1)
deb = false
game.World.Button1.Color = Color(255,0,0) --red
end
end
link(game.World.Button1.Collided, onCollide)[/lua]
I think that's correct.
By the way, you misspelled "deb = false" and wrote "dep = false" towards the end.
Posts: 112
Threads: 22
Joined: Apr 2011
Reputation:
0
@Paradox
anonymous functions = efficiency