Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

OnTouched function doesnt connect, any ideas why?

Asked by 3 years ago

so im just watching peaspod tutorial, and i tried a other variation of a touch event and it doesnt work. can anyone explain why? heres the code:

function OnTouched()
    script.Parent.BrickColor = BrickColor.new("Baby blue")  

end

script.Parent.Touched:connect(OnTouched)
0
Does anything appear in console? virushunter9 943 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I see nothing wrong with your code. Everything should work exactly as it should be. If that method didn't work for you, then maybe try to this (--comments included.):

script.Parent.Touched:Connect(function() --Instead of connecting an existing function, let's connect an anonymous function instead, since we're using it only once.
    script.Parent.BrickColor = BrickColor.new("Baby blue")
end)

Also, capitalise the Connect as connect is deprecated.

Ad

Answer this question