(r6)
So I was making my script for a sword, but the M2 script won't work. it says that OnServerEvent can only be used on the server. (There is a Remote Event that the M2 references.)
local m2 = game.ReplicatedStorage.Combat:WaitForChild("Punch2Player")
local tweenService = game:GetService("TweenService")
m2.OnServerEvent:Connect(function(player)
local character = player.Character
local Track5 = Instance.new("Animation")
Track5.AnimationId = "rbxassetid://5740595758"
local Anim5 = character.Humanoid:LoadAnimation(Track5)
Anim5:Play()
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("HumanoidRootPart") and v:FindFirstChild("Humanoid") and v ~= character then
if (v.HumanoidRootPart.Position - character.HumanoidRootPart.Position).Magnitude < 4 then
if v.HumanoidRootPart:FindFirstChild("Block") then
v.BlockBar.Value = 0
else
local hiteffect = game.ReplicatedStorage.Combat:WaitForChild("SlashEffect"):Clone()
hiteffect.CFrame = v.HumanoidRootPart.CFrame * CFrame.Angles(0,math.rad(177.5),math.rad(-90))
hiteffect.BrickColor = BrickColor.new("Persimmon")
hiteffect.Parent = workspace
game.Debris:AddItem(hiteffect,0.5)
local info3 = TweenInfo.new(0.3,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local goal3 = {}
goal3.Size = hiteffect.Size * 3
goal3.Transparency = 1
local tween3 = tweenService:Create(hiteffect,info3,goal3)
tween3:Play()
print("played3")
print("you both hit at the same time")
v.Humanoid:TakeDamage(15)
local bv = Instance.new("BodyVelocity",v.HumanoidRootPart)
bv.MaxForce = Vector3.new(1e8,1e8,1e8)
bv.Velocity = character.HumanoidRootPart.CFrame.lookVector*80
game.Debris:AddItem(bv,0.3)
end
end
end
end
end)
The error is apparently at line 4, And I can't see the error in that line, anybody help?

2 comments
The script normally has every requirement in it including animations and the other script, where should I put it?
Don't worry, the error has been fixed!