Hello, im trying to make a anchor player thing for something in my studio, and when i put name in the "NAME" area it works. But when there is number in front of it, it doesn't work and there is a red line. How do i fix? (Sorry for bad english and im also not good at verbally explaining stuff and sorry for the very small image down below)
original code: game.Players.NAME.Character.HumanoidRootPart.Anchored = true
edited code (using a friends name): game.Players.3KingsOfEgypt.Character.HumanoidRootPart.Anchored = true
image: https://imgur.com/JYIanFW
Use :FindFirstChild() for player name, here is the fixed code:
game.Players:FindFirstChild("NAME").Character.HumanoidRootPart.Anchored = true
This will work even with numbers in a player's name
local plr_name = game.Players.USERNAME local plr = game.Workspace:FindFirstChild(plr_name) plr.Character.HumanoidRootPart.Anchored = true
Kinda the same the script as Lord_WitherAlt's one.
Here's another way to do it because why not.
game.Players["playernamehere"].Character.HumanoidRootPart.Anchored = true