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

Script that sets parts in a model to the color of the name of a gui?

local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:connect(function(click)
	local plrName = plr.Name
	local Workspace = game.Workspace
	local cartName = plrName..Cart
	local cart = Workspace..cartName
	for i,v in pairs (cart:GetChildren()) do
		if v.Name == "Changable" then
			v.Color = BrickColor.new(script.Parent.Name)
		end
	end
end)

I'm trying to get a script that I won't have to customize to work with other colors*

I have a color palette gui and now I'm trying to get the buttons to color parts in workspace the color of their name? I hope its possible because I've tried having one script to do it all but I would have to have it be HUGE with every single color which I'm trying to avoid. Please help xD

1 comment

0

Ask me to explain parts more I realise this is a bit confusing :)

1 answer

There are so many wrong things in this script, unfortunately. ):

--Problem 1
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
--Suggested to use a LocalScript in the TextButton so you can use:
local plr = Game.Players.LocalPlayer

--Problem 2
script.Parent.MouseButton1Click:connect(function(click)
--"click" isn't really needed, Suggestion:
script.Parent.MouseButton1Click:connect(function()

--Problem 3
local Workspace = game.Workspace
--Not needed, just chill and use "Workspace", nothing else.

--Problem 4
--You can't use plr.Name to put bricks in.. As plr.Name is a string value...

--Problem 5
local cartName = plrName..Cart
local cart = Workspace..cartName
--Why are you using concatenations on a value? That's only for strings, bro.
--Correction:
local cartName = plrName.Cart
local cart = Workspace.cartName
--Still, it's really confusing, I don't know what you're trying to do here, the name of these values

--Problem 6
v.Color = BrickColor.new(script.Parent.Name)
--According to the brick's properties, in the studio property window, it's:
v.BrickColor = BrickColor.new(script.Parent.Name)

If you have questions, ask me, but I think you should go back to basics, you're missing a lot of scripting basic lessons, you just can't script something like that if you don't know the basics and use them properly.

1 comment

0

Yea, I know my basics :P I just tried to use the ".." on a value to combine the players name with "cart" like PLayer1Cart. I wasn't sure how to do that and I haven't scripting in a couple months :P. How would I find Playersname..Cart and change it to color of the name of the gui button? Still a little lost but thank you for your help :)

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