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

-"player is not a valid member of Player" ?

I am trying to make a teleport button and I've got everything expect the script part.
I put the script in and I keep getting: player is not valid member of Player
Here is my script
script.Parent.MouseButton1Click:connect(function() game.Players.LocalPlayer.player.LowerTorso.CFrame = CFrame.new(workspace.Point.Position)
end)
What does this mean and how do I fix it?

2 answers

You would put:

game.Players.LocalPlayer.Character.LowerTorso.CFrame = CFrame.new(workspace.Point.Position)

The property in the player that is their character model (in the workspace) is called Character.

I will help you, Ricanbabyy

Ok, so, the second 'player' you wrote, you're referring to player's character. To do so, you should do the follow:

When referring to the person's character,

Instead of using

game.Players.LocalPlayer.player --(.anything)

You should ALWAYS use:

game.Players.LocalPlayer.Character --(.anything)

So, in your code:

script.Parent.MouseButton1Click:connect(function() 		
	game.Players.LocalPlayer.player.LowerTorso.CFrame = CFrame.new(workspace.Point.Position)
end)

You should use:

script.Parent.MouseButton1Click:connect(function() 		
	game.Players.LocalPlayer.Character.LowerTorso.CFrame = CFrame.new(workspace.Point.Position)
end)

Still, there's a bug that will make that not work on the actual game. So, your full script would be:

--Wait for LocalPlayer's Character child. This is a typical ROBLOX bug, but will work if you write this down.
repeat wait() until game.Players.LocalPlayer.Character

script.Parent.MouseButton1Click:connect(function() 		
	game.Players.LocalPlayer.Character.LowerTorso.CFrame = CFrame.new(workspace.Point.Position)
end)

Since in any of our scripts, or yours that doesn't work, or on mine that should be working, you're using LocalPlayer, you shouldn't use a Regular Script, but a LocalScript.

Hope I was helpful.

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