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

Click script?

Asked by 10 years ago

How do i make a script that when a player clicks a brick the brick changes colors?

3 answers

Log in to vote
1
Answered by 10 years ago

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)
Ad
Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
10 years ago

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)
Log in to vote
0
Answered by 7 years ago

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.

Answer this question