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

player is refusing to die?

so this is the code i use to make a humanoid take damage:

hit.Parent.Humanoid:TakeDamage(100)

but when it reaches 0 (i already conformed it did reach 0 with a print statement) it doeen't die why won't it die?

this is the script in the serverscriptservice:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("Damage")
remoteEvent.OnServerEvent:Connect(function(plr,dmg)
	print(plr, "serverscriptservice")
	print(dmg, "serverscriptservice")
end)

this is the code in the local script

game.ReplicatedStorage:WaitForChild("Damage"):FireServer(hit.Parent.Name,"50")
print(hit.Parent.Name)
print("50")

so for the serverscriptservice script the output is MY name then the thing i hit but it should be the thing i hit and the damage (which is a number) and for the local script the output is their name and the damage so how come it changes? and where does it get my name from? EDIT: i realized that before all of the variables it automatically makes it so the first var is the player that is running it so the new script is:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("Damage")
remoteEvent.OnServerEvent:Connect(function(me,plr,dmg)
	game.Workspace:FindFirstChild()
end)

2 comments

0

Can you show us more of the script?

0

why? the hit.parent does run i conformed it with a print statement

2 answers

✓ Accepted answer

The problem might be the fact that you are damaging the player from the client. If you kill the player through a local script, he won't actually die.

So, I recommend using a remote event to damage the player.

4 comments

0

this is a good idea but this is my first time using remote events so i looked it up and there are a few bugs in my code

0

(ill show the code on the answer)

0

can you show the full code? (how you are detecting the 'hit')

0

Nvm got it to work! Thx

The function :TakeDamage() only works if the player doesn't have a forcefield. Try just setting the health to 0.

hit.Parent.Humanoid.Health = 0

1 comment

0

well first of all players don't spawn with forcefeilds 2nd the player might not always die like im scripting a gun and the bullets might not always one shot a player

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