Hello in me and my friends upcoming RPG game we had problems because Humanoid.TakeDamage (Damage Here) would deal the damage but deal it from 100 even if a players health is at 500, i have tried activating and deactivating a local script with that code there but it happens to deal damage to all players and not just one since the npc script is a normal script i don’t know how to make the npc local, even the default roblox zombie does this too, so is there anyway to fix this if a player is at a higher health level it deals damage from that health.
Is it a Touched event?
You should try making it a Touched event.
Try subtracting the humanoid instead of using TakeDamage
Humanoid.Health = Humanoid.Health -Amount
A touched event i could try that.
Whats the difference between TakeDamage and substracting
There isn’t a huge difference, but sometimes it might be better to subtract the players health manually under certain circumstances, I’ve seen posts saying that it doesn’t work sometimes . In my opinion subtracing the players health can be more reliable. Also I believe Take Damge only works when a Torso/HumanoidRootPart is present( I could be wrong)
game.Players.PlayerAdded:Connect(function(plr)
while wait(1)do
local UpperTorso = script.Parent.UpperTorso – the torso of the npc / if the rig is a r6 then changethe UpperTorso to Torso
local Hum = script.Parent.Humanoid
local character = game.Workspace:WaitForChild(plr.Name)
local charupper = character:WaitForChild(“UpperTorso”) or character:WaitForChild(“Torso”)
local charhum = character:WaitForChild(“Humanoid”)
local deb = true – DONT MESS WITH THIS IT WILL BREAK THE INBETWEEN TIME
UpperTorso.Touched:Connect(function(hit)
if hit.Parent == character then
if deb == true then
deb = false
charhum.Health = charhum.Health - 1 – the ammount you want it to go buy
wait(2)-- time between the hits
deb = true
end
end
end)
end
end)