Hello, I’m OriginalDevelops, totally, I’m just a new scripter, I’m trying to make a punch system has damage base on player stats value! This is a script so it can happend on server, but it didnt work . I’ve trying to make on a local script, it work correctly but the problem is it only happend in the client when kill a people! ( I mean the player that kill a people only happend on a client! And the people got kill still alive and not respawning, on their client still alive!) .This is my code :
Left PunchDamage
local debounce = false
script.Parent.Equipped:Connect(function()
local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)
local char = player.Character or player.CharacterAdded:Wait()
local leftarm = char:WaitForChild("LeftHand")
leftarm.Touched:Connect(function(hit)
if not debounce then
debounce = true
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= char.Name then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - (player.Stats.Strength.Value + 1)
print(hit)
wait(0.5)
debounce = false
end
end
end)
end)
Right Punch Damage :
local debounce = false
script.Parent.Equipped:Connect(function()
local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)
local char = player.Character or player.CharacterAdded:Wait()
local rightarm = char:WaitForChild("RightHand")
rightarm.Touched:Connect(function(hit)
if not debounce then
debounce = true
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= char.Name then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - (player.Stats.Strength.Value + 1)
print(hit)
wait(0.5)
debounce = false
end
end
end)
end)
I wish someone can fix this for me so I can complete a part of my game!
You have a tool, and you may wanna insert a RemoteEvent into the Tool
and then get a server script to handle the Remote Event
by for example
Tool:WaitForChild(“RemoteEvent”).OnServerEvent:Connect(function(Player,Info1,Info2)
end)
every remoteEvent give out player info first so remember that
now you wanna replicate your info from client by Tool:WaitForChild(“RemoteEvent”):FireServer(informations)
info1,info2 came from the Client side, You can send as many info as you want
Oh, so that mean when I fire a Remote in a local script, then I put hit value in then in the fireserver line, I put script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, hit)) so that will get the hit object right?
Should be something like this
–Local Script–
Tool.RemoteEvent:FireServer(Humanoid,Damage)
–Server Script–
Tool.RemoteEvent.OnServerEvent:Connect(function(player,Humanoid,Damage)
if Humanoid then
Humanoid.Health = Humanoid.Health - Damage
end
end)