Problems retrieving player's hand information via local script

Hey there, I’ve hit a roadblock and have searched for about a few hours now and I’m not finding anything particularly useful.

I’m trying to get the players Right Hand with a tool so I can mount a Motor6D’s Part0 attachment to the players Right Hand using a local script inside the tool.

For right now, I’m just trying to get the player’s hand just so I can understand what to utilize once it comes to the function.

Here is my current work, it is saying that there is an Infinite yield when attempting to retrieve the hand’s information. Not sure how to get around this other than using the method I have displayed.

local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:Wait()
end

if character then
	print("Successful. - " ..character.Name)
end

local hand = character:WaitForChild("RightHand")

if hand then
	print("Successful. - " ..hand.Name)
end

Any help will be much appreciated, thank you.

That code you are showing seems to work fine for me.
You mean that its not working when using a tool?

Well, it just passes me an infinite yield upon equipping it, and it also doesn’t work if I have it just as a character script.

Mmhh so weird. I pasted your code as a local script in character scripts, and it found the player’s hand and printed it in output succesfuly…
And I did this in a local script inside a tool and works too:

local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

tool.Equipped:Connect(function()
      warn(character:FindFirstChild("RightHand"))
end)

It just has my output as my character name, nil.

pretty weird, for me both ways works…
image

I just ran a hard reset on Studio and it seems to be working properly.

1 Like

Thank you for the help though, at least I know it works properly now, much appreciated.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.