I have this shirt script that if you have a value, you should be able to get this shirt. Its giving me the shirt without the value though, any help?
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player:WaitForChild("clothes").DShirt.Value>= 1 then wait(0.1) local d = character:GetChildren() for i=1, #d do if (d[i].className == "Shirt") then d[i]:remove() end end end local h = script.Parent.DShirt:Clone() h.Parent = character print("dshirt should work") wait(.1) end) end)
The way you looped through the table is not recommended, as you just made it harder for yourself. You should use a for i,v in pairs(TableName)do
loop its built in by roblox. I is the index (the amount of iterations) and v is the value (in this case its the object).
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player:WaitForChild("clothes").DShirt.Value>= 1 then wait(0.1) local d = character:GetChildren() for i,v in pairs(d) do if v.ClassName == "Shirt" then v:Remove() end end end local h = script.Parent.DShirt:Clone() h.Parent = player.Character print("dshirt should work") wait(.1) end) end)
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player:WaitForChild("clothes").DShirt.Value>= 1 then wait(0.1) local d = character:GetChildren() for i,v in pairs(d) do if v.ClassName == "Shirt" then v:Remove() end end end local h = script.Parent.DShirt:Clone() h.Parent = player.Character print("dshirt should work") wait(.1) end) end)
I tried making this let me know if it helped!