I am trying to make a sword
When I use the sword my character moves forward and backwards over and over:
from this:
to this:
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:
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)