- I basically made a system where you can kick and it will damage your opponent.
- since I am a beginner I stumbled into a problem that is allied with the way I scripted the combat system. the problem is that after I kick the damage OnTouch still goes on.
here you can see the problem
https://gyazo.com/8042f85d2d58e83b1292733174c522bf
here is the damage script.
local remote = game.ReplicatedStorage.Kick
function sussify(player)
print(player)
local canDamage = Instance.new("BoolValue")
canDamage.Name = "canDamage"
canDamage.Parent = player
print(player)
canDamage.Value = false
end
-- firing all the player exist [first player]
table.foreach(game.Players:GetPlayers(), function(i, p) sussify(p) end)
game.Players.PlayerAdded:Connect(sussify)
remote.OnServerEvent:Connect(function(plr, player)
player.canDamage.Value = true
if player.canDamage.Value == true then
player.canDamage.Value = false
player.Character["Right Leg"].Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(2)
player.canDamage.Value = false
else
return
end
end)
end
end)