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

Why Won't This Script For Making a Player Stand Still By Disabling the ControlScript Work?

In my game, battles are organized periodically between two players. At the start of each one, the two players are supposed to be placed a few dozen studs away, facing one another. I don't want the players to be able to walk around during this point, so I decided it'd be best to keep them still until the battle actually starts. To do this, I tried disabling the ControlScript, which is a script inside of all Players that controls their ability to move via input from the keyboard and mouse. However, when I did this, the game told me that PlayerScripts is not a valid member of player. But when I test this in Studio, I can clearly see that PlayerScripts IS in the player! So why is this happening? I'm genuinely confused.

This is my script. I don't wanna have to anchor the player's torso, as that would restrict the R15 idle animations, which I'd really like to keep. If the way I'm going about it isn't going to work, is there any way I can keep a player completely still and looking in the same direction while preserving the R15 animations?

function teleportToBattle(p1, p2)
	player1 = game.Players:FindFirstChild(p1.Name) --Finding the players.
	player2 = game.Players:FindFirstChild(p2.Name)
	if player1 and player2 then --If they are both present.
		player1.PlayerScripts.ControlScript.Disabled = true --The part that disables the player's ability to move.
		player1.Character.Torso.CFrame = CFrame.new(Vector3.new(-62, 8, -89.5)) --Teleports tthem to their respective position.
		player1.Character.HumanoidRootPart.Rotation = Vector3.new(0, -90, 0) --To make them face one another.
		player2.PlayerScripts.ControlScript.Disabled = true --This too.
		player2.Character.Torso.CFrame = CFrame.new(Vector3.new(-48, 8, -89.5))
		player2.Character.HumanoidRootPart.Rotation = Vector3.new(0, 90, 0)
	elseif player1 and not player2 then --In case one leaves or lags out.
		print("player1 wins")
	elseif player2 and not player1 then
		print("player2 wins")
	else
		print("no one wins")
	end
end

3 comments

0

You could just make their walkspeed and jumppower 0, couldn't you?

0

Also if your game is filtering enabled then the Control Script would need to be accessed via the player through remote events

0

I've tried that, but when the players teleported, they weren't standing; they had flailed around by the time they reached their spot and were no longer standing. Weird...

1 answer

PlayerScript / PlayerGui (And maybe backpack) can not be accesed from the server IF you have FE on.

You should use the anchor idea you had, but on the Character.HumanoidRootPart. This is an invisible part the R6 and R15 both have.

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