Players.benraupp123.PlayerScripts.Placemaker:10: attempt to index nil with 'RightHand' pls help

image

It means that the RightHand doesn’t exist or the character doesn’t exist.

1 Like

How do i fix this then?

30tehcharacters

You need to wait for the character to be loaded, you can do this:

local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()

Not sure if this will fire when you join the first time.

1 Like

Says righthand is not a valid member of model

It is because only R15 has a right hand, R6 doesn’t.

It means there is no child in the Character’s model named RightHand.

Edit: What @Lyyrezism also said.

Im using r15?

30tehcharacterse

Hey dude, character loads have some mysterious behavior behind them. When the characterAdded event fires, you’ll notice that it doesn’t have any children. So you’ll want to put in a wait for whatever objects you’re accessing from a character object.

  • Note: This behavior only happens client side, while client waits for character’s children to be replicated.

This behavior can be tested with this code on client
local player=game:GetService('Players').LocalPlayer
player.CharacterAdded:Connect(function (char)
	local charChildren=char:GetChildren()
	
	-- Immediately after connection fires, print all children names of character
	print('Immediately after character created')
	for i,v in pairs(charChildren) do
		print(v.Name)
	end
	
	-- Stop for a minute
	wait(1)
	print('After 1 Second: \n ')
	
	-- Try again
	charChildren=char:GetChildren()
	for i,v in pairs(charChildren) do
		print(v.Name)
	end
end)

For future reference as well, whenever you have a ‘attempt to index nil with “so and so”’, it always means the parent of “so and so” is not defined.

This is just a mess.
The code i provided worked in the past i don’t know whats wrong.

repeat wait() until script.Parent:IsA("Model")

local mouse = game.Players.LocalPlayer:GetMouse()

local object = Instance.new("Attachment",script.Parent:WaitForChild("RightHand"))

object.Name = "Grappleattach"

object.Position = script.Parent:WaitForChild("RightHand").Position

Put this into a localscript inside StarterCharacterScripts

If you’re putting this into a tool, tell me so I can write a version to work with a tool script.

Here try this:

local Players = game:GetService("Players")

local localPlayer = Players.localPlayer
local localChar = localPlayer.Character or localPlayer.CharacterAdded:wait() -- Wait for character
game:GetService('RunService').RenderStepped:wait() -- Wait for character to fully replicate to client

local mouse = localPlayer:getMouse()

local object = Instance.new("Attachment")
object.Name="Grappleattach"
object.Parent=localChar.RightHand
object.Archivable=true
object.Position=localChar.RightHand.Position

Works great!!!
30tehcharacters

1 Like

That also works when I tested it.

3 Likes