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

after the I rebirthed, I won't die nor does the tools in my StarterGear clear, why?

Asked by
0msh 333 Moderation Voter
6 years ago
Edited 6 years ago

this is the lines where the script don't work. It works perfect in studio but not in game. The tools in StarterGear won't be destroyed even if "keepAfterRe" is false.

    local items = player.StarterGear:GetChildren()
        for i = 1, #items do
            if items[i].keepAfterRe.Value == false then
                items[i]:Destroy()
            end
        end
        local char = player.Character
        local h = char:FindFirstChild("Humanoid")
        h.Health = 0

1 answer

Log in to vote
0
Answered by 6 years ago

If there is no error then your problem is probably you didn't use :WaitForChild(). Try it before saying it's not the problem.

local items = player.StarterGear:GetChildren()
    for i = 1, #items do
        if items[i].keepAfterRe.Value == false then
            items[i]:Destroy()
        end
    end
    local char = player.Character or player.CharacterAdded:Wait() -- or makes it so that if player.Character is nil than it goes to player.CharacterAdded:Wait()
    local h = char:WaitForChild("Humanoid") -- WaitForChild
    h.Health = 0
    h.Health = 10000000 - h.Health -- just in case

I hope you have your ends. But, give it a try. If this helped you, please Upvote and accept answer.

-- Your orange, BlackOrange3343

0
well... it was my bad, I accidentally looped it. Thanks for your reply, but for your sake, I'll accept answer. 0msh 333 — 6y
0
Thanks! BlackOrange3343 2676 — 6y
Ad

Answer this question