-
What do you want to achieve?
The tool is not appearing in the player’s hand and then disappears after one click. -
What is the issue?
-
What solutions have you tried so far?
I’ve checked the properties and script but I can’t find anything that’s been causing the issue cause I’m not sure what’s causing it to begin with.
Additional Information:
Sword Script in ServerScript:
local cooldowns = {}
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local m6d = Instance.new("Motor6D", character.RightHand)
m6d.Part0 = character.RightHand
m6d.Name = "ToolM6D"
end)
end)
game.ReplicatedStorage.SwordRE.OnServerEvent:Connect(function(player, instruction, bodyAttach)
if instruction == "connectm6d" then
player.Character.RightHand.ToolM6D.Part1 = bodyAttach
elseif instruction == "disconnectm6d" then
player.Character.RightHand.ToolM6D.Part1 = nil
elseif instruction == "attack" then
if cooldowns[player] then return end
cooldowns[player] = true
game.ReplicatedStorage.SwordRE:FireAllClients(bodyAttach)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
local raycastResults = workspace:Raycast(player.Character.HumanoidRootPart.Position, player.Character.HumanoidRootPart.CFrame.LookVector * 3, raycastParams)
if raycastResults and raycastResults.Instance.Parent:FindFirstChild("Humanoid") then
raycastResults.Instance.Parent.Humanoid:TakeDamage(20)
end
wait(0.5)
cooldowns[player] = false
end
end)
Sword Script in the Sword:
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local idleAnim = character:WaitForChild("Humanoid"):LoadAnimation(script.IdleAnimation)
local animCombo = {
character:WaitForChild("Humanoid"):LoadAnimation(script.Swing1Animation),
character:WaitForChild("Humanoid"):LoadAnimation(script.Swing2Animation),
character:WaitForChild("Humanoid"):LoadAnimation(script.Swing3Animation),
}
local currentCombo = 1
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.SwordRE:FireServer("connectm6d", script.Parent.BodyAttach)
character.RightHand.ToolM6D:GetPropertyChangedSignal("Part1"):Wait()
idleAnim:Play()
end)
script.Parent.Unequipped:Connect(function()
game.ReplicatedStorage.SwordRE:FireServer("disconnectm6d")
idleAnim:Stop()
end)
local cooldown = false
script.Parent.Activated:Connect(function()
if cooldown then return end
cooldown = true
game.ReplicatedStorage.SwordRE:FireServer("attack", script.Parent.BodyAttach)
animCombo[currentCombo]:Play()
character.HumanoidRootPart.Velocity = character.HumanoidRootPart.CFrame.LookVector * 100 * Vector3.new(1, 0, 1)
currentCombo += 1
if currentCombo > #animCombo then currentCombo = 1 end
local previousCombo = currentCombo
spawn(function()
wait(3)
if currentCombo == previousCombo then
currentCombo = 1
end
end)
wait(0.5)
cooldown = false
end)
game.ReplicatedStorage.SwordRE.OnClientEvent:Connect(function(bodyAttach)
bodyAttach.Slash:Play()
bodyAttach.Trail.Enabled = true
wait(0.3)
bodyAttach.Trail.Enabled = false
end)
Thank you for your time!