I made this script and I haven’t realized it until I did a local server test. And I was wondering if there is a way to turn this into server side. and can I make this server side without Rewriting the whole script
What Server sees:
https://gyazo.com/4b0e73a558002c65b2f4e2a3e0d8ccdc
What Others see:
https://gyazo.com/2a7d31da8bbc947285590214c1ffc5c5
What Client/Player sees:
https://gyazo.com/8d15be0830ff819537a9186167e0b0ce
Main swords script location:
https://gyazo.com/c6e3d2d8041c2f93d6ce904b581c5a9b
local t = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local resources = rs.Combat["Sword/Powers"]
local fx = resources["Wolf Knights Greatsword"]
local remote = rs.Remotes.Combat
local p = game.Players.LocalPlayer
local c = script.Parent
local hrp = c.HumanoidRootPart
local combo = 1
local lasthit = 0
local cd = false
local anim = script:WaitForChild("Animation")
local function setUp(char)
local handle = fx.Handle:Clone()
handle.Parent = char
local m6d = Instance.new("Motor6D", handle)
m6d.Part0 = char["Right Arm"]
m6d.Part1 = handle
m6d.C1 = CFrame.new(0,.125,0)
local model = fx.MeshPart:Clone()
model.Parent = workspace.Fx
local weld = Instance.new("Weld", model)
weld.Part0 = handle
weld.Part1 = model
weld.C1 = CFrame.new(-0.50,-2.75,0.3) * CFrame.Angles(math.rad(90),0,139.8)
end
for i,v in pairs(game.Players:GetChildren()) do
repeat wait() until v.Character
setUp(v.Character)
v.CharacterAdded:Connect(function(char)
char:WaitForChild("Right Arm")
setUp(char)
end)
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:WaitForChild("Right Arm")
setUp(char)
end)
end)
local function slash(char, comboN)
local m = fx.Slash:Clone()
local hrp = char.HumanoidRootPart
if comboN == 1 then
wait(.8)
m.CFrame = hrp.CFrame * CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(30),math.rad(-15))
t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
elseif comboN == 2 then
wait(.8)
m.CFrame = hrp.CFrame * CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(30),math.rad(0))
t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
elseif comboN == 3 then
wait(.9)
m.CFrame = hrp.CFrame * CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(30),math.rad(-15))
t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
elseif comboN == 4 then
wait(1)
m.CFrame = hrp.CFrame * CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(30),math.rad(235))
t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
elseif comboN == 5 then
wait(1)
m.CFrame = hrp.CFrame * CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(30),math.rad(0))
t:Create(m, TweenInfo.new(.5), {CFrame = hrp.CFrame * CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
end
t:Create(m.light, TweenInfo.new(.4), {Brightness = 0}):Play()
local count = 1
local connection
connection = game["Run Service"].RenderStepped:Connect(function()
m.Mesh.TextureId = textures[count]
count = count + 1
if count > #textures then
count = 1
connection:Disconnect()
end
end)
m.Parent = workspace.Fx
if char == c then
local hb = Instance.new("Part", workspace.Fx)
hb.Size = Vector3.new(10,3,7)
hb.CFrame = hrp.CFrame * CFrame.new(0,0,-5)
hb.Anchored = true
hb.CanCollide = false
hb.Transparency = .6
hb.Name = "hb"
hb.Material = Enum.Material.ForceField
hb.CanQuery = false
local con
con = hb.Touched:Connect(function()
con:Disconnect()
end)
local hits = {}
for i,v in pairs(hb:GetTouchingParts()) do
if v:IsDescendantOf(char) == false then
if v.Parent:FindFirstChildWhichIsA("Humanoid") and table.find(hits, v.Parent) == nil then
table.insert(hits, v.Parent)
end
end
end
if #hits == 0 then
local bv = Instance.new("BodyVelocity",char.PrimaryPart)
bv.MaxForce = Vector3.new(99999,0,99999)
bv.Name = "v"
bv.P = 10
game.Debris:AddItem(bv,.2)
if comboN == 5 then
bv.Velocity = char.PrimaryPart.CFrame.LookVector * 20
else
bv.Velocity = char.PrimaryPart.CFrame.LookVector * 5
end
end
local data = {hb = hits, action = "hit", combo = comboN, c = char}
remote:FireServer(data)
hb:Destroy()
end
end
uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 and cd == false and c:FindFirstChild("Stun") == nil then
c.Humanoid.WalkSpeed = 1
c.Humanoid.JumpHeight = 0
if tick() - lasthit > 300 then
combo = 1
end
lasthit = tick()
cd = true
anim.AnimationId = swingAnims[combo]
local load = c.Humanoid:LoadAnimation(anim):Play()
local data = {char = c, comboN = combo, action = "slash"}
remote:FireServer(data)
slash(c, combo)
if combo == 5 then
combo = 1
else
combo = combo + 1
end
wait(.1)
cd = false
c.Humanoid.WalkSpeed = 16
c.Humanoid.JumpHeight = 7.2
end
end)