I keep getting an "attempt to call a nil value" in my output every time I click on a button, here's my scripts.
local clickDetector = script.Parent.ClickDetector if script.Parent.Parent.Name == ("Can I get a burrito?") then function onMouseClick() script.Parent.Parent.Name = ("Thank you!") end end clickDetector.MouseClick:connect(onMouseClick)
Note that the first script is the same for every name text
while true do creativlyNamedVariable = math.random (1, 4) if creativlyNamedVariable == 1 then script.Parent.Name = ("Can I get a taco?") elseif creativlyNamedVariable == 2 then script.Parent.Name = ("Can I get some nachos?") elseif creativlyNamedVariable == 3 then script.Parent.Name = ("Can I get a burrito?") elseif creativlyNamedVariable == 4 then script.Parent.Name = ("Can I get a soda?") if script.Parent.Name == ("Thank you!") then wait(30.8) creativlyNamedBye = math.random (1, 3) if creativlyNamedBye == 1 then script.Parent.Name = ("Bye!") elseif creativlyNamedBye == 2 then script.Parent.Name = ("Cya!") elseif creativlyNamedBye == 3 then script.Parent.Name =("Alright, have a good one!") end end end wait(35.8) end
EDIT: So I just tested it again. But it works with some buttons one time, and then others when I test it another time.
Well I found it out
local clickDetector = script.Parent.ClickDetector function onMouseClick() if script.Parent.Parent.Name == ("Can I get a burrito?") then script.Parent.Parent.Name = ("Thank you!") end end clickDetector.MouseClick:connect(onMouseClick)
Just needed to put line 3 into the function. Now it works every time!