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

Remote Event wont work after humanoid dies?

Asked by 4 years ago

When a player touches a part it takes damage, but when the player dies then respawns and touches the same part the player isn't taking damage.

LocalScript inside StarterPlayerScripts:

local player = game.Players.LocalPlayer local playername = player.Name local humanoid = game.Workspace:WaitForChild(playername) local realhumanoid = humanoid.Humanoid

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(player, hit) print("ok,ok") realhumanoid:TakeDamage(10) end)

Script in Part in Workspace:

script.Parent.Touched:Connect(function(hit) print(hit) local realplayer = hit.Parent.Name local realplayer2 = game.Players:FindFirstChild(realplayer) if hit.Parent:FindFirstChild("Humanoid")then print("ok") game.ReplicatedStorage.RemoteEvent:FireClient(realplayer2, hit) end end)

0
You should not deal damage locally. You should be dealing it from the server. DeceptiveCaster 3761 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Heres a quick script i put together it should do what you want.

script.Parent.Touched:connect(function(touched)
    local humanoid = touched.Parent:FindFirstChild("Humanoid")
    if humanoid ~= nil then 
        --humanoid.Health = 0 -- player takes 10 damage / doesnt work if they have force field
        humanoid.Health = humanoid.Health - 10 -- player takes 10 damage / works if they have force field
    end
end)

i couldn't fully understand what you meant but hopefully this does what you need! What it should look in the explorer

1
Thank you ewdoggypoopoo 12 — 4y
Ad

Answer this question