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)
Heres a quick script i put together it should do what you want.
1 | script.Parent.Touched:connect( function (touched) |
2 | local humanoid = touched.Parent:FindFirstChild( "Humanoid" ) |
3 | if humanoid ~ = nil then |
4 | --humanoid.Health = 0 -- player takes 10 damage / doesnt work if they have force field |
5 | humanoid.Health = humanoid.Health - 10 -- player takes 10 damage / works if they have force field |
6 | end |
7 | end ) |
i couldn't fully understand what you meant but hopefully this does what you need! What it should look in the explorer