Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
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

Log in to vote
1
Answered by
lunatic5 409 Moderation Voter
5 years ago
Edited 5 years ago

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
0
 use :FindFirstChildOfClass("Shirt") so it wont get mixed up with other stuff called "Shirt" or "Clothing" User#23365 30 — 5y
0
Yeah, that's probably a better idea although I can't imagine the character having another other child in it called Shirt. lunatic5 409 — 5y
Ad

Answer this question