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

Coloring a brick but only for a player?

Im making a paintbrush game but i cant seem look up tutorials for this. Specifically, players can color a part but only if the part is theirs. Like the color customizer in Critical Strike... I dont know what this is called because my explanation is too broad. Please help me.

Code: (this was put inside the customizer [in a normal script])

local part = game.Workspace.Brick1
local customizer = script.Parent --part's color is orange

function onMouseClick()
	part.BrickColor.new = ("Br. yellowish orange")
end
 
clickDetector.MouseClick:connect(onMouseClick)

Thank you for any support given.

3 comments

0

(i made this in notepad so there maybe an error inside this

0

BrickColor.new("Br. yellowish orange")

0

Local script only for one player, events by the server is for everyone.

2 answers

✓ Accepted answer

Replace line 5 to this:

part.BrickColor = BrickColor.new("Br. yellowish orange")

And if you want the player to color the part that belongs to them then you would need to use an if statement. For example, a way you could do this is by having a tag with the players name:

local part = game.Workspace.Brick1
local customizer = script.Parent
clickDetector.MouseClick:Connect(function(plr) -- plr = the plyer that clicked
	if part:FindFirstChildOfClass("StringValue")then -- Check if the part have a tag
		if part:FindFirstChildOfClass("StringValue").Value = plr.Name then  -- Check if the value of the tag is equal to the clicker's name
			part.BrickColor = BrickColor.new("Br. yellowish orange")
		end
	end
end)

Besides, I'm not sure where you get the 'clickDetector' from. So I suppose that you should have this in your script:

local clickDetector = customizer.ClickDetector -- you need a reference to the click detetor

Hope this helps.

1 comment

0

very much what i asked. thanks

Make it a localscript, and make sure the game has FE enabled under workspace too.

1 comment

1

The FE property is deprecated, so turning on/off FE won't do anything.

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