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

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

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

6 comments

0

You can do a repeat check until and then check() the health and then u can do what happens i think

0

Are TheWallOfFlesh and WallOfFlesh different things?

0

Or it could be filtering enabled,is that a local script?

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.

0

Yes. TheWallOfFlesh and WallOfFlesh are different things

0

Also i already figured this out by turning it into a local script

1 answer

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!

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