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

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

this is the script,

function onClick(clicked)
    game.Workspace.DanceFloor.Part1.BrickColor = BrickColor.new("random")to happen
script.Parent.MouseButton1Down:connect(clicked)

2 comments

0

please help

0

Technically, you should implement BrickColor.random(), using BrickColor.new() can choose specific colors.

1 answer

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.

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