-
What do you want to achieve? Keep it simple and clear!
i’m recreating the linked sword as a local sided script for my game (single player game btw) -
What is the issue? Include screenshots / videos if possible!
the user moves, but the sword doesnt. here’s what i mean:
Normal Linked Sword:
My Linked Sword:
-
What solutions have you tried so far?
couldn’t find any solution
here’s the code:
--// PLAYER VARIABLES \\--
local player = game.Players.LocalPlayer
local character = player.Character
--// TOOL VARIABLES \\--
local tool = script.Parent
local handle = tool.Handle
--// SOUNDS \\--
local slashSound = handle.SwordSlash
local lungeSound = handle.SwordLunge
local equipSound = handle.Unsheath
--// SCRIPTING \\--
local hitboxModule = require(game.ReplicatedFirst.Modules.Hitbox)
local runService = game:GetService("RunService")
local mouse = player:GetMouse()
local active = false
function playAnimation(animation)
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = animation
Anim.Parent = tool
end
--// ATTACK FUNCTIONS \\--
local equipped = false
function slash()
task.spawn(function()
active = true
playAnimation("Slash")
slashSound:Play()
task.wait(0.05)
for count = 1, 10 do
task.wait(0.01)
hitboxModule:CreateHitbox(character, handle.CFrame, Vector3.new(5,5,5), 5)
end
task.wait(0.5)
active = false
end)
end
function lunge()
active = true
hitboxModule:CreateHitbox(character, handle.CFrame, Vector3.new(5,5,5), 5)
playAnimation("Lunge")
lungeSound:Play()
task.wait(0.5)
active = false
end
local lastRightClick = 0
tool.Enabled = true
function activate(click : string)
if equipped == true and tool.Enabled == true and active == false then
if click == "Left" then
tool.Enabled = false
slash()
tool.Enabled = true
elseif click == "Right" then
tool.Enabled = false
local attackDelay = runService.Stepped:wait()
if (attackDelay - lastRightClick < 0.2) then
lunge()
end
lastRightClick = attackDelay
tool.Enabled = true
end
end
end
tool.Equipped:Connect(function()
equipped = true
equipSound:Play()
end)
tool.Unequipped:Connect(function()
equipped = false
end)
mouse.Button1Down:Connect(function()
activate("Left")
end)
mouse.Button2Down:Connect(function()
activate("Right")
end)