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

can someone for the life of me tell me at least what is wrong with this script?

I've been trying for literally 3 hours now and i'm probably the stupidest person in this place right now but what am I doing wrong with this script???

local h = script.Parent.Parent.Parent.edit_label.Part.Value
local d = game.Players.LocalPlayer.Data
local c = script.color.Value
local n = script.Parent.Name
local head = script.Parent.Parent.Parent.Hat
local torso = script.Parent.Parent.Parent.Torso
local larm = script.Parent.Parent.Parent.Larm
local rarm = script.Parent.Parent.Parent.Rarm
local lleg = script.Parent.Parent.Parent.Lleg
local rleg = script.Parent.Parent.Parent.Rleg

script.Parent.MouseButton1Click:connect(function()
	if h == "head" then
		head.BackgroundColor3 = Color3.fromRGB(c)
		d.headcolor = n
	if h == "torso" then
		torso.BackgroundColor3 = Color3.fromRGB(c)
		d.torsocolor = n
	end
	end
end)

this is a fraction of the script and it wont even work, but what it is supposed to do is check which part of the body the player is editing and if it is that part of the body to change that color, but every time I do this it will only change the head or change nothing.

if anyone can actually fix this I will praise you.

2 comments

0

Do you want to change the vars "h,n,c" during the game? If yes, you should set it on player click

0

I suggest you clean up your variables by creating a new one that points to script.Parent.Parent.Parent directly.

1 answer

Now to fix the entire script, we would need you to produce the entire script. But for now, this should fix this element of the script.

local h = script.Parent.Parent.Parent.edit_label.Part.Value
local d = game.Players.LocalPlayer.Data
local c = script.color.Value
local n = script.Parent.Name
local head = script.Parent.Parent.Parent.Hat
local torso = script.Parent.Parent.Parent.Torso
local larm = script.Parent.Parent.Parent.Larm
local rarm = script.Parent.Parent.Parent.Rarm
local lleg = script.Parent.Parent.Parent.Lleg
local rleg = script.Parent.Parent.Parent.Rleg

script.Parent.MouseButton1Click:Connect(function()
    if h == "head" then
        head.BackgroundColor3 = Color3.fromRGB(c)
        d.headcolor = n
    elseif h == "torso" then
        torso.BackgroundColor3 = Color3.fromRGB(c)
        d.torsocolor = n
    end
end)

Also don't use :connect, it's depreciated, use :Connect.

1 comment

0

it still turns the head color to black when I click the torso

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