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

i am trying to get rid of the players shirt if they have one but it wont work how do i fix?

game.ReplicatedStorage.Transfromgold.Trans.OnServerEvent:Connect(function(plr)
	
	local unfrom = false

local chr = plr.Character

local ref = game.Workspace.Part
local hum = chr:WaitForChild("Humanoid")
local InputService = game:GetService("UserInputService")
	
	for _,body in pairs(chr:GetChildren()) do
		if body:IsA("BasePart") then
			body.BrickColor = BrickColor.new("Gold")
			body.Material = "Neon"
		end
		for _,size in pairs(hum:GetChildren())do
			if size:IsA("NumberValue") then
				size.Value = 5
							
		
			end
		local shirt = chr:WaitForChild("Shirt")
		shirt:Destroy()
			-- "BodyDepthScale" or "BodyWidthScale" or "HeadScale" then
					--resize.Value = 7
		hum:WaitForChild("BodyDepthScale").Value = 10
		hum:WaitForChild("BodyWidthScale").Value = 7.89
		hum:WaitForChild("HeadScale").Value = 6
		hum.WalkSpeed = 41
		hum.JumpPower = 77
		unfrom = true

		end
	end
end)

1 answer

✓ Accepted answer

You need to check if there is a shirt in the first place. Otherwise, you may receive the error "Infinite yield possible on ____". You should use a conditional statement and :FindFirstChild() for this. You can use something like the following to do so:

if chr:FindFirstChild("Shirt") then
	chr.Shirt:Destroy()
end

2 comments

0

 use :FindFirstChildOfClass("Shirt") so it wont get mixed up with other stuff called "Shirt" or "Clothing"

0

Yeah, that's probably a better idea although I can't imagine the character having another other child in it called Shirt.

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