Hi so I was making a very small project to practice scripting, so the project is when you step on a part a ball changes colors, but when I try it, I touch the ball with my feet and it doesn't work . the ball is called discoball and the part is called button
here is the code:
local discoball = game.Workspace.discoball
local button = game.Workspace.button
function activatediscoball ()
discoball.Material = Enum.Material.Neon
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
end
button.Touched:Connect(activatediscoball())
Thank you in advance
Edit: Now I have edited it into this:
local discoball = game.Workspace.discoball
local button = game.Workspace.button
button.Touched:Connect(function()
discoball.Material = Enum.Material.Neon
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
discoball.color = Color3.fromRGB(255, 0, 0)
wait (0.25)
discoball.color = Color3.fromRGB(0, 255, 0)
wait (0.25)
discoball.Color = Color3.fromRGB(0, 0, 255)
wait (0.25)
end)
So after editing, I have put a bracket next to the end on the end, and have removed the event of touched and have put it on the beginning, i have removed the name of the function and have put in the brackets of the connect in the touched event, still doesnt work, it tells me in the output that color isn't a valid member of part Workspace.discoball
plz help

1 comment
Thank You :)