How do i make a script that when a player clicks a brick the brick changes colors?
✓ ANSWER ACCEPTED
Click script?
3 answers
✓ Accepted answer
First add a Click Detector to the Part then do this
EX.
local Part = script.Parent
local ClickDetector = Part.ClickDetector
ClickDetector.MouseClick:connect(function(Player)
Part.BrickColor = BrickColor.random()
end)
Like the other answer add a Click Detector then do this:
local p = script.Parent
local cd = script.Parent.ClickDetector
function onClicked()
p.BrickColor = BrickColor.random()
end
cd.MouseClick:connect(onClicked)
If you don't want to use a click detector, try this:
wait()
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Target = game.Workspace.DesiredPart
game.Workspace.Baseplate.BrickColor = BrickColor.rand
end
end)
DesiredPart is the part that you want the button to be.
This discussion is preserved as it was. New answers, comments, and votes are closed.
