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

how do I make my touch skin color into a click skin color?

how do I make this script so that instead of touching a part when the player clicks on the gui button he gets his head colored to the color of the button

function onTouched(part) 
player = game.Players:GetPlayerFromCharacter(script.Parent) 
if player ~= nil then 
part.Parent.Head.BrickColor = script.Parent.BrickColor 
end 
end 
script.Parent.Touched:connect(onTouched)

1 comment

0

If you want to get the player i updated the code for you.

1 answer

✓ Accepted answer

What you need to do is insert a ClickDetector inside the part and replace the code with

https://wiki.roblox.com/index.php?title=API:Class/ClickDetector/MouseClick

script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
local player = playerWhoClicked
if player ~= nil then 
playerWhoClicked.Character.Head.BrickColor = script.Parent.BrickColor
end 
end)

1 comment

0

Updated btw if u wanna get the player

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