It means that the RightHand doesnât exist or the character doesnât exist.
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.
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
That also works when I tested it.