i have a script here:
game.Players.PlayerAdded:Connect(function(player) local user = player.Character player.Chatted:Connect(function(msg) if msg == "code:123!x556" then user.HumanoidRootPart.Position = Vector3.new(0,0,0) end end) end)
and i have this error Workspace.Script:5: attempt to index nil with 'HumanoidRootPart' i dont even know what this means lol help please
The issue here is that you are calling the HumanoidRootPart before it is loaded into the game.
A quick fix to this would be adding a
to your code.
The finished version is below!
local secretMessage = 'test' game.Players.PlayerAdded:Connect(function(plr) local char = plr.Character or plr.CharacterAdded:Wait() plr.Chatted:Connect(function(messageSent) if messageSent == secretMessage then char.HumanoidRootPart.Position = Vector3.new(0,0,0) end end) end)
The error could be because you're calling the character immediately. In most cases, the character doesn't load as soon as the player joins, so you can try replacing
local user = player.Character with
local user = player.CharacterAdded:Wait() so the character is retrieved when it is loaded.