Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My character position changes whenever I equip my tool?

GIF Below

https://gyazo.com/3130ce334e3d77d5e1763363f3566972

This has been happening to all my tools, I've asked this question a couple times but the answer is always "Unanchor Parts" or "Change CustomPhysicalProperties Density" which hasn't worked. Help would be appreciated.

tool = script.Parent
local player = game.Players.LocalPlayer or game.Player:WaitForChild("LocalPlayer")
character = player.Character or player:WaitForChild("Character")
rhand = character:FindFirstChild("RightHand")
hum = character.Humanoid
jitte = tool.Jitte

tool.Equipped:connect(function()
    jitte.CFrame = rhand.CFrame * CFrame.new(0,0,-3.2)
    local weld = Instance.new("Weld")
    weld.Parent = tool
    weld.Part0 = jitte
    weld.C0 = jitte.CFrame:inverse()
    weld.Part1 = rhand
    weld.C1 = rhand.CFrame:inverse()
    jitte.Anchored = false
end)

2 comments

0

This indicated a part in your tool is anchored. Unanchored it.

0

No offence, but did you even read what I wrote? There's only a single part and it is Unanchored.

1 answer

✓ Accepted answer

Because you're setting the jitte's CFrame, then creating a weld where it's the Part0, then asking the right hand to offset that Part0.

You could assign the hand to the weld's Part0 instead, but tools have a built in weld methodology using a part named 'Handle', and a Grip property where Tool.Grip is the weld's offset; so there isn't a real requirement for you to do that in Lua.

I'm a fan of not using roblox's provisions due to limitations and in effect I don't use any Tool instances; so I would recommend just flip flopping the welds Part0 and Part1 as preferable over using the Grip property.

This discussion is preserved as it was. New answers, comments, and votes are closed.