Trying to make a purchase and equip system and this textlabel script is not working:
local player = game:GetService("Players").LocalPlayer
while wait(.1) do
if player:WaitForChild(script.Parent.Parent.Parent.Name).Value == true then
local Cash = math.floor(script.Parent.Parent.Parent.Price.Value)
local IsType = (function (T)
T = tostring(T)
return T:reverse():gsub("%d%d%d", "%1,"):reverse():gsub("^,", "")
end)
script.Parent.Text = "$" .. IsType(Cash)
elseif player:WaitForChild(script.Parent.Parent.Parent.Name).Value == false then
if player:WaitForChild("Hat").Value == script.Parent.Parent.Parent.Name then
script.Parent.Text = "Equipped"
else
script.Parent.Text = "Equip"
end
end
end
the script CostumeInator clones the contents and adds them to hats in a folder
Yes but that’s probably not the issue, WaitForChild is probably a better option.
Also, player:WaitForChild(script.Parent.Parent.Parent.Name) is there because the parent changes to TrenchCoat
Well, it’s supposed to say “$1,000” before you buy it, then once you have it, it should say “Equip” and if its equipped, it says “Equipped.”
What about player:WaitForChild("Hat")? Is that supposed to wait for a child of class “Hat”? Because WaitForChild only looks for any Instance named by the given string, or in this case, any object named “Hat”.
Also, using WaitForChild looks to be too abusive of the feature based on your code, mixed with countless CostumeInator scripts looping every tenth of a second.
With the waitforchild("Hat) is not the same as waitforchild(script.parent.parent.parent.Name). waitforchild(script.parent.parent.parent.Name) means “TrenchCoat.” But trenchcoat isnt the only hat. I’m not going to make an individual script for each hat.