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

i tryed to make a tap to change block to different random color, why dosnt it work?

Asked by 7 years ago
Edited by shayner32 7 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

this is the script,

function onClick(clicked)
    game.Workspace.DanceFloor.Part1.BrickColor = BrickColor.new("random")to happen
script.Parent.MouseButton1Down:connect(clicked)
0
please help AndyTheScriptKiddie6 10 — 7y
0
Technically, you should implement BrickColor.random(), using BrickColor.new() can choose specific colors. rexbit 707 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

What is this monstrosity of code? Okay, so first you should've specified if this was a local script that is parented to the player or a script parented to the brick. If it's the former then use this.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

function onClick()
    game.Workspace.DanceFloor.Part1.BrickColor = BrickColor.random()
end

mouse.Button1Down:connect(onClick)

Otherwise if the script is parented to the brick then you're gonna want to use a clickdetector and use this code instead.

local click = script.Parent.ClickDetector

function onClick()
    script.Parent.BrickColor = BrickColor.random()
end

click.MouseClick:connect(onClick)

This should work and you're welcome.

Ad

Answer this question