Sword Glitching out and Rotating my character

I am trying to make a sword

When I use the sword my character moves forward and backwards over and over:
from this:
image
to this:
image

I didn’t use any other than the forum and google for collisions.

My sword works fine when I activate it but the problem is when I do it is like someone grabbed building tool by F3X and then rotated me 360 Degrees. I have all my parts in the tool as can collide false and not anchored. I do have welds to keep the tools parts together. Explorer:
image
There is no errors in the output either.

--//Client
--// Variables \\--
local Tool = script.Parent
local MainFolder = Tool:WaitForChild("MainFolder")
local MainObjects = MainFolder:WaitForChild("MainObjects")
local ClientEvents = MainFolder:WaitForChild("ClientEvents")

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Debounce = false
local UserInputService = game:GetService("UserInputService")
local CursorGui = MainObjects:WaitForChild("CursorGui")

--// Events \\--
Tool.Equipped:Connect(function()
	local CloneGui = CursorGui:Clone()
	CloneGui.Parent = Player:WaitForChild("PlayerGui")
	CloneGui.Cursor.Image = "http://www.roblox.com/asset/?id=7017552074"
	CloneGui.Cursor.Position = UDim2.new(0,Mouse.X,0,Mouse.Y)
	
	UserInputService.MouseIconEnabled = false
end)

Tool.Unequipped:Connect(function()
	local Gui = Player:WaitForChild("PlayerGui"):WaitForChild("CursorGui")
	Gui:Destroy()
	
	UserInputService.MouseIconEnabled = true
end)

Tool.Activated:Connect(function()
	Player:WaitForChild("PlayerGui"):WaitForChild("CursorGui"):WaitForChild("Cursor").Image = "http://www.roblox.com/asset/?id=7022875295"
	ClientEvents.AttackEvent:FireServer("true")
	
	if not MainObjects.Attacked.Value then return end
	
	ClientEvents.AttackEvent:FireServer("false")
	Player:WaitForChild("PlayerGui"):WaitForChild("CursorGui"):WaitForChild("Cursor").Image = "http://www.roblox.com/asset/?id=7017552074"
end)

Mouse.Move:Connect(function()
	
	if not Player:WaitForChild("PlayerGui"):FindFirstChild("CursorGui") then return end
	
	Player:WaitForChild("PlayerGui"):FindFirstChild("CursorGui").Cursor.Position = UDim2.new(0,Mouse.X,0,Mouse.Y)
	
end)
--//Server
--// Variables \\--
local Tool = script.Parent
local MainFolder = Tool:FindFirstChild("MainFolder")
local MainObjects = MainFolder:FindFirstChild("MainObjects")
local ClientEvents = MainFolder:FindFirstChild("ClientEvents")
local Parts = Tool:FindFirstChild("Parts")

--// Events \\--
ClientEvents["AttackEvent"].OnServerEvent:Connect(function(Player,value)
	if value:lower() == "true" then
		Parts.RootJoint.Size = Parts.Blade.Size
		Parts.RootJoint.CFrame = Parts.Blade.CFrame
	elseif value:lower() == "false" then
		Parts.RootJoint.Size = Vector3.new(0,0,0)
		Parts.RootJoint.CFrame = Parts.Blade.CFrame
	end
end)

Parts.RootJoint.Touched:Connect(function(obj)
	
	MainObjects.Attacked.Value = true
	
	local character = obj:FindFirstAncestorWhichIsA("Model")
	
	if not character then return end
	
	local human = character:FindFirstChildWhichIsA("Humanoid")
	
	if not human then return end
	
	human:TakeDamage(10)
	
end)

The MainFolder has nothing but the objects for the GUI’s and the Events

(Sorry for the poorly made code I am kinda new)

This glitch always occurs and I don’t know how to fix this.

I cant say for sure but I think it is because of the welds being glitchy and weird

How would I fix this than? chars

I had similar issues with welds breaking tools in some of my projects. I couldn’t figure out how to fix it directly, so I ended up scripting a workaround that basically replaced the tools with fake ones that attaches using Humanoid:AddAccessory

I do not know how to use humanoid:AddAccessory() I am slightly new to coding

Its pretty simple. You first have to create a new accessory instance, then parent your weapon mesh to the accessory, and humanoid:AddAccessory(accessory) automatically attaches it. You do have to add an attachment to your weapon mesh though, then name it the corresponding attachment on a character where it should be attached.

For example a simple sword. You would place an attachment at the handle of the sword, then name the attachment “RightGripAttachment” if you want to hold it in the right hand. You can find all the attachment places by inserting a character with rig builder

Okay thank you I will try this but I need to make a accessory in the tool and change to the player with human:AddAccessory()? and then parent the tool in it?

so for e.g.:

human:AddAccessory(workspace.AccessoryName); --// This will add the accessory to the character?

No tool, since welds usually break them. With accessories you can have as many welds as you like and there won’t be any issues (probably). But you do have to script your own equip system as well

What does that mean I can’t just make it so I press 1 normally without coding to equip it?

and would this work?

--serverscript in serverscriptservice
local accessory = script.Accessory
local human = workspace.Dogeco0l.Humanoid

human:AddAccessory(accessory)

Sadly yes. You can’t just equip without coding, since it is not a tool. It gives more freedom and welds don’t break it, but you also have to script more stuff.

1 Like

and the accessory has the handle and stuff

yes that should work
3030303030

1 Like

I will reach out to you if I need any help on it.

1 Like