Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't my onTouched paint gun won't work for some reason?

So, I've named all the parts in my game which you can paint "Paintable". All the other scripts in the paint gun work, it is enabled, but for some reason this part won't work. Can anyone please fix it?

function onTouched(hit)
    if hit.Parent.Name == "Paintable" then
        hit.Parent.Color = Color3.new(255/255,0/255,0/255)
end
end
script.Parent.Touched:connect(onTouched)

2 comments

0

Is this in a local script or a server script?

0

server script inside spray part inside gun

1 answer

✓ Accepted answer

You're checking to see if the part's parent is named 'Paintable'. So if you touched a part named paintable, your script is looking to see if it's parent is named paintable, which it's not because it's parent is most likely named 'Workspace'. Simply change that part of the script to if hit.Name == "Paintable" then

2 comments

0

Done that, but it still doesn't work.

1

nvm, thank you! I had to change a bit of stuff in my scripts for it to work.

This discussion is preserved as it was. New answers, comments, and votes are closed.