SCRIPT :
local replicatedStorage = game:GetService('ReplicatedStorage')
local PunchingRemote = replicatedStorage:WaitForChild('Punch')
local anim1 = Instance.new('Animation')
local anim2 = Instance.new('Animation')
anim1.AnimationId = 'http://www.roblox.com/asset/?id=6985138442'
anim2.AnimationId = 'http://www.roblox.com/asset/?id=6984519609'
local var = 1
local debounce = false
local canDoDmg = true
PunchingRemote.OnServerEvent:connect(function(plr)
local track1 = plr.Character.Humanoid:LoadAnimation(anim1)
local track2 = plr.Character.Humanoid:LoadAnimation(anim2)
local character = plr.Character
local humanoid = character:WaitForChild('Humanoid')
if var == 1 and debounce == false then
debounce = true
plr.leaderstats.Effort.Value = plr.leaderstats.Effort.Value + plr.Stats.Earnings.Value
track1:Play()
var = var + 1
wait(1)
debounce = false
elseif var == 2 and debounce == false then
debounce = true
plr.leaderstats.Effort.Value = plr.leaderstats.Effort.Value + plr.Stats.Earnings.Value
track2:Play()
var = 1
wait(1)
debounce = false
end
plr.Character.RightHand.Touched:connect(function(hit)
if hit.Parent.Humanoid and canDoDmg then
hit.Parent.Humanoid:TakeDamage(plr.Stats.Damage.Value)
canDoDmg = false
wait(1)
canDoDmg = true
end
end)
plr.Character.LeftHand.Touched:connect(function(hit)
if hit.Parent.Humanoid and canDoDmg then
hit.Parent.Humanoid:TakeDamage(plr.Stats.Damage.Value)
canDoDmg = false
wait(1)
canDoDmg = true
end
end)
end)
while wait(4) do
if var == 2 then
var = 1
end
end
LocalScript :
local UIS = game:GetService('UserInputService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local remotePunch = replicatedStorage:WaitForChild('Punch')
UIS.InputBegan:connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.F then
remotePunch:FireServer()
end
end)
Basically, when i go next to a play and my hand touches his body it deals damage anyway, and i want it to deal damage only when i press a certain key. Please teach me, i don t want a script i want an explanation so i can understand it and learn it for further projects !

1 comment
what did it do in reality, not expectations