Hello, so I’ve made a combat system with some VFX but for some reason, in the studio, it works as intended but, in-game it works really slow.
Here is an example:
Studio:
https://gyazo.com/9406e490566445ad9674f6a6915466cc
Game:
https://gyazo.com/91b5c41b2d243384bb34b11136a12dcf
Client Script:
Mouse.Button1Down:Connect(function()
if ready and not Char:FindFirstChildWhichIsA("Tool") and InAMove == false and InAKeybindMove == false then
InAMove = true
InAPunch = true
-- // Counting
PunchCount = PunchCount + 1
-- // Animations & Cooldown
Remote4:FireServer(PunchCount,Mouse.Hit)
spawn(function()
if PunchCount >= 10 then
PunchCount = 0
end
end)
Punch(PunchCount)
ready = false
wait(0.15) -- cooldown
InAPunch = false
ready = true
InAMove = false
end
end)
Server Script:
game.ReplicatedStorage.remotes.PunchEvent.OnServerEvent:Connect(function(plr,punchcount,Mouse)
local Char = plr.Character or plr.CharacterAdded:Wait()
local Cooldown = false
local HitBoxPart
local Ready = true
local function HitBox()
HitBoxPart = Instance.new("Part",workspace)
HitBoxPart.CanCollide = false
HitBoxPart.Name = "HitBox"
HitBoxPart.Size = Vector3.new(6, 6, 6)
HitBoxPart.Transparency = 1
HitBoxPart.Anchored = false
HitBoxPart.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0,0,-1)
local weld = Instance.new("WeldConstraint")
weld.Part0 = HitBoxPart
weld.Part1 = Char.HumanoidRootPart
weld.Parent = HitBoxPart
HitBoxPart.Touched:Connect(function(h)
if h.Parent:FindFirstChild('Humanoid') and h.Parent.Name ~= plr.Name and Cooldown == false then
-- // Hit Confirmation & Hit Information Processing
game.ReplicatedStorage.remotes.HitConfirmation:FireClient(plr,HitStatus)
-- // Combat Effects
local ehrp = h.Parent:FindFirstChild("HumanoidRootPart")
----------------------------------------
local X = math.random(-180,180)
local Y = math.random(-180,180)
local Z = math.random(-180,180)
spawn(function()
local HBeam = HitBeam:Clone()
HBeam.Parent = workspace
HitBeam.CFrame = CFrame.new((ehrp.CFrame * CFrame.new(0, 0, 0)).Position, Mouse.Position) * CFrame.Angles(0, math.rad(0), 0)
spawn(function()
for i = 1,50 do wait()
HBeam.Size = HBeam.Size + Vector3.new(0.15,0.15,0.5)
HBeam.Transparency = HBeam.Transparency + 0.1
end
end)
Derbis:AddItem(HBeam,1.2)
end)
end
-- // ---------------
if not h.Parent:FindFirstChild("Humanoid") then
return
end
local Enemy = h.Parent.Humanoid
Enemy:TakeDamage(5)
spawn(function()
Enemy.WalkSpeed = 0
wait(1)
Enemy.WalkSpeed = 16
end)
if game.Players:FindFirstChild(h.Parent.Name) then
wait(0)
Knockback:FireClient(game.Players:FindFirstChild(h.Parent.Name))
end
Cooldown = true
wait(0.5)
Cooldown = false
end)
Derbis:AddItem(HitBoxPart,0.2)
end
HitBox()
end)
I thought maybe the problem is the hit processing on server… But I am not sure.
Thank you for your time