Everything in my script works except for when its supposed to take damage, its a local script and uses a remote event to damage the player.
–Here’s The Script
local plr = game.Players.LocalPlayer
local Players = game:GetService("Players")
local Playing = false
local mouse = plr:GetMouse() or task.wait(plr:GetMouse())
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local Animator = hum:WaitForChild("Animator")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://18239370085"
local animTrack = Animator:LoadAnimation(anim)
-- 18239203600
mouse.Button1Down:Connect(function ()
if mouse and Playing == false then
Playing = true
for _, player in pairs(Players:GetChildren()) do
local OneCharacter = player.Character or player.CharacterAdded:Wait()
local distance = (char.PrimaryPart.Position - OneCharacter.PrimaryPart.Position).Magnitude
if distance < 20 and player.Name ~= plr.Name then
game.ReplicatedStorage.PlayerPunch:FireServer(OneCharacter)
end
end
animTrack:Play()
animTrack:AdjustSpeed(animTrack.Length * 1.5)
task.wait(animTrack.Length * 1.5)
end
end)
while true do
if Playing == true then
task.wait(animTrack.Length * 2)
Playing = false
end
task.wait(0.001)
end
–Here’s The Server Script
game.ReplicatedStorage.PlayerPunch.OnServerEvent:Connect(function (plr, OneChar)
local hum = OneChar:WaitForChild("Humanoid") or OneChar:FindFirstChild("Humanoid")
hum.Health -= 10
print("tookHealth")
end)
–