Tool not appearing in player's hand and then disappearing

  1. What do you want to achieve?
    The tool is not appearing in the player’s hand and then disappears after one click.

  2. What is the issue?

  3. 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)

Screen Shot 2022-06-15 at 12.03.06 PM

Thank you for your time!

Do you have a handle in the tool? Or is RequiresHandle set to false?

2 Likes

RequiresHandle is set to false. Perhaps it’s the attachments? (I don’t want to have a handle on the tool because then the animations are removed).

I also found out why it would disappear—the collision was off so it was falling through the map. However, now the issue is that it’s not being held by the player.

Output says: ToolM6D is not a valid member of MeshPart “Workspace.Auevi.RightHand”

I’m somewhat new to scripting so I’m not sure what this means or how to fix it so I’d appreciate some help :slight_smile: