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

Shirt script isnt working Any help? Thanks

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)

1 comment

0

I have no idea where you got the DShirt if you deleted it in line 15

2 answers

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)

5 comments

0

When you said for i,v inpairs(d) do, did u mean in pairs? or in Ipairs

0

in pairs sorry bout the typo

0

Its alright.

0

For some reason, I still spawn with it even though I have no value?

0

You should not be using Remove / wait in your code :/ -1

  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!

7 comments

0

Crossing my fingers :D

0

Its the same as the last one, which sadly didn't work.

0

off

0

Alright.

0

eh i guess i dont know then

0

what is this ?

0

The script this guy made is copied from the guy above.

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