local damage = 10
local db = false
local function KnockBack(character)
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e8,1e8,1e8)
bv.Velocity = character.HumanoidRootPart.CFrame.lookVector * 20
bv.Parent = character.HumanoidRootPart
game.Debris:AddItem(bv, 0.1)
end
script.Parent.Damage.OnServerEvent:Connect(function(plr, humanoid)
if db then
plr:Kick()
return
end
db = true
humanoid:TakeDamage(damage)
print(damage)
wait(0.5)
if db then
print("Damage event completed.")
db = false
else
print("Another damage event occurred before completion.")
end
end)
type or paste code here
Humanoid:TakeDamage will replicate from the server. There is no reason to do the damage on the client. Just cut the client out of the damage entirely and damage the player on the server.
this is Clientside Projectlie to ask server to fire event to allClients that this player created it Projectlie
type or paste code here
local rs = game:GetService('ReplicatedStorage')
local fire = rs:WaitForChild('Fire')
local remove = game:GetService("Debris")
local db = false
local function KnockBack(character,plr)
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e8,1e8,1e8)
bv.Velocity = character.HumanoidRootPart.CFrame.lookVector * -50
bv.Parent = character.HumanoidRootPart
game.Debris:AddItem(bv, 0.1)
end
fire.OnClientEvent:Connect(function(player,ServerChair)
local chair = ServerChair.PrimaryPart:Clone()
chair.Position = player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.LookVector * 2
chair.Parent = workspace.Debris
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 100
bv.Parent = chair
remove:AddItem(bv,.1)
remove:AddItem(chair,5)
chair.Touched:Connect(function(hit)
local PlayerOnTouch = game.Players:GetPlayerFromCharacter(hit.Parent)
if db then return end
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and hit.Parent ~= player.Character then
db = true
script.Parent.Parent.Damage:FireServer(humanoid,PlayerOnTouch)
KnockBack(humanoid.Parent)
wait(0.5)
db = false
end
end)
end)