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

Humanoid kill script works in studio, but not in real game?

Asked by 5 years ago
Edited 5 years ago

It's about checking if a humanoid is killed, it gets deleted. What am I doing wrong?

Here's the script

while true do
    wait()
    workspace.TheWallOfFlesh:WaitForChild("Zombie")
    if workspace.TheWallOfFlesh.Zombie.Health < 1
    then workspace.WallOfFlesh:Destroy()
    workspace.Fleshpart:Destroy()
    workspace.Fleshpart2:Destroy()
    workspace.Fleshpart3:Destroy()
    workspace.Fleshpart4:Destroy()
    workspace.Fleshpart5:Destroy()
    workspace.Fleshpart6:Destroy()
    workspace.Fleshpart7:Destroy()
    local splode = Instance.new("Explosion")
    splode.Parent = workspace.TheWallOfFlesh.Head
    script.Parent.Text = "The Wall of Flesh Has been defeated!"
    wait()
    end
end
0
You can do a repeat check until and then check() the health and then u can do what happens i think MaxDev_BE 55 — 5y
0
Are TheWallOfFlesh and WallOfFlesh different things? Pojoto 329 — 5y
0
Or it could be filtering enabled,is that a local script? DatRainbowTee 49 — 5y
0
Humanoid has .HealthChanged and .Died event listeners. For your application I suggest you use .Died, as that will check when the Humanoid’s Health actually hits 0 (you can have health values between 0-1) instead of constantly looping through this and eating up resources. Phantom1996 45 — 5y
View all comments (2 more)
0
Yes. TheWallOfFlesh and WallOfFlesh are different things Jaska008 0 — 5y
0
Also i already figured this out by turning it into a local script Jaska008 0 — 5y

1 answer

Log in to vote
0
Answered by
Axdrei 107
5 years ago

Hello, Jaska!

Are you calling your script from a server script or from a localscript? Your script needs to be called from server and I suggest using .Died event to check when the humanoid died.

Your script would look like that

local Humanoid = workspace.TheWallOfFlesh:WaitForChild("Zombie")
Humanoid.Died:Connect(function()
    for i = 1, 7 do
        workspace:FindFirstChild("Fleshpart" .. i):Destroy()
    end
    local splode = Instance.new("Explosion")
    splode.Parent = workspace.TheWallOfFlesh.Head
    script.Parent.Text = "The Wall of Flesh Has been defeated!"
    wait()
end)

If you have any questions, feel free to ask them!

Ad

Answer this question