Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Equipping my tool is causing my player character to rotate and move?

Asked by 6 years ago
Edited 6 years ago

Before Responding Please Read Below Writing

Part Is Already Un-Anchored Changing Physical Density Has Not Fixed The Problem Interchanging The Welds Part0 and Part1 Changed Nothing Question has been asked many times but none of the answers so far have worked

Tool Hierarchy https://gyazo.com/1d013fb71494a3a44a8acbee751f96b5

GIF Of Problem https://gyazo.com/db1296909ec848ef5530dce9f9b47753

Equipping the tool for the first time usually doesn't cause any problems, but any subsequent equips does.

local play = game.Players.LocalPlayer
char = play.Character
hum = char:WaitForChild("Humanoid")
rhand = char:WaitForChild("RightHand")
tool = script.Parent
sword = tool.LawSword

tool.Equipped:connect(function()
    workspace.LawSwordSheathed.Transparency = 1
    workspace.Sheath.Transparency = 0
    sword.CFrame = rhand.CFrame * CFrame.new(0,1.75,-4)
    sword.CFrame = sword.CFrame * CFrame.Angles(3.7,0,1.45)
    local weld = Instance.new("Weld")
    weld.Parent = sword
    weld.Part0 = sword
    weld.C0 = sword.CFrame:inverse()
    weld.Part1 = rhand
    weld.C1 = rhand.CFrame:inverse()
    sword.Anchored = false
end)

tool.Unequipped:connect(function()
    workspace.LawSwordSheathed.Transparency = 0
    workspace.Sheath.Transparency = 1
end)

EDIT: Problem doesn't occur if I have handlerequired enabled on the tool, the issue with this is that I dont want the hand to be positioned like that when using a handle.

1
first of all i just want to compliment you on how amazing your sword looks, you're a super talanted builder Elixcore 1337 — 6y
1
talented* Elixcore 1337 — 6y
0
Thanks :) nicktooner 119 — 6y

2 answers

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

OMG I fixed it, wow. Took me literally a week of trial and error and over 50 tools. If anyone else is having this issue do this below

ORIGINAL CODE

local play = game.Players.LocalPlayer
char = play.Character
hum = char:WaitForChild("Humanoid")
rhand = char:WaitForChild("RightHand")
tool = script.Parent
sword = tool.LawSword

tool.Equipped:connect(function()
    workspace.LawSwordSheathed.Transparency = 1
    workspace.Sheath.Transparency = 0
    sword.CFrame = rhand.CFrame * CFrame.new(0,1.75,-4)
    sword.CFrame = sword.CFrame * CFrame.Angles(3.7,0,1.45)
    local weld = Instance.new("Weld")
    weld.Parent = sword
    weld.Part0 = sword
    weld.C0 = sword.CFrame:inverse()
    weld.Part1 = rhand
    weld.C1 = rhand.CFrame:inverse()
    sword.Anchored = false
end)

tool.Unequipped:connect(function()
    workspace.LawSwordSheathed.Transparency = 0
    workspace.Sheath.Transparency = 1
end)

CHANGED CODE

local play = game.Players.LocalPlayer
char = play.Character
hum = char:WaitForChild("Humanoid")
rhand = char:WaitForChild("RightHand")
tool = script.Parent
sword = tool.LawSword

sword.CFrame = rhand.CFrame * CFrame.new(0,1.75,-4)
sword.CFrame = sword.CFrame * CFrame.Angles(3.7,0,1.45)

tool.Equipped:connect(function()
    workspace.LawSwordSheathed.Transparency = 1
    workspace.Sheath.Transparency = 0
    local weld = Instance.new("Weld")
    weld.Parent = sword
    weld.Part0 = sword
    weld.C0 = sword.CFrame:inverse()
    weld.Part1 = rhand
    weld.C1 = rhand.CFrame:inverse()
    sword.Anchored = false
end)

tool.Unequipped:connect(function()
    workspace.LawSwordSheathed.Transparency = 0
    workspace.Sheath.Transparency = 1
end)

Basically the cause of the issue was that the C Frame was being reset every-time the tool was equipped, so taking the Parts C Frame's out of the Equipped Function fixes it.

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Not sure if this is a simple solution to your problem but I use this plugin to edit how I want the player to hold the tool: https://www.roblox.com/library/153352998/Tool-grip-editor

Then I make an animation for the character of the tool if I want the left hand of the character to also be gripping the tool. Also I make sure this animation is looped. Then when the player equips the tool I load and play the animation which shows them holding the tool as I want.

--this is the basic outline I use


local function onEquip()
    local player = game.Players.LocalPlayer
    local example = player.Character.Humanoid:LoadAnimation(script.Parent.Animation)
    example:Play()
end


tool.Equipped:connect(onEquip)

Just make sure to stop the animation when you unequip the tool

Answer this question