You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I want to make a new Motor6D when the Tool is Equipped and delete it when the tool is Unequipped -
What is the issue?
The Motor6D isn’t Created (its called Motor7D) and the Tool is placed at the origin
also the tool has RequireHandle = False
(its supposed to look like this on the character)
Here is The Code:
--local script(inside the Tool)
local tool = script.Parent
local Player = game:GetService("Players").LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local Hum = char:FindFirstChildOfClass("Humanoid")
local Animator = Hum:WaitForChild("Animator")
local AnimIdle = Instance.new("Animation")
AnimIdle.AnimationId = "rbxassetid://11759349459"
local AnimIdleTrack = Animator:LoadAnimation(AnimIdle)
AnimIdleTrack.Priority = Enum.AnimationPriority.Idle
AnimIdleTrack.Looped = true
tool.Equipped:Connect(function()
game:GetService("ReplicatedStorage").Events.OnToolEquip:FireServer(char, tool)
AnimIdleTrack:Play()
end)
tool.Unequipped:Connect(function()
game:GetService("ReplicatedStorage").Events.OnToolunEquip:FireServer(char, tool)
AnimIdleTrack:Stop()
end)
--script (ServerScriptService)
local RP = game:GetService("ReplicatedStorage").Events
RP.OnToolEquip.OnServerEvent:Connect(function(plr, char, tool)
local Torso = char:FindFirstChild("UpperTorso")
local m6d = Instance.new("Motor6D")
m6d.Parent = char:FindFirstChild("UpperTorso")
m6d.Part0 = Torso
m6d.Part1 = tool.BodyAttach
m6d.Name = "Motor7d"
end)
RP.OnToolunEquip.OnServerEvent:Connect(function(plr, char, tool)
local m6d = char:FindFirstChild("UpperTorso").Motor7d
m6d:Destroy()
end)
if there is anything that i should improve in my code plz notify be about it