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

The script works in studio but not online, any help?

(Edited so the question applies more)

beepada = script.Parent

script.Parent.ClickDetector.MouseClick:connect(function(PlayerWhoClicked)
	if PlayerWhoClicked.userId == 613323 or PlayerWhoClicked.userId ==  game.CreatorId then
		game.Workspace.Player.Torso.CFrame = game.Workspace.zzzzzzzzz.CFrame
			
		end
end)

1 answer

✓ Accepted answer

What you need to do is replace the

       game.Workspace.Player.Torso.Position = game.Workspace.Player.Torso.Position * (CFrame.new(-242.799, -0.517, -128.892))

With this:

       game.Workspace.Player.Torso.CFrame = game.Workspace.Player.Torso.CFrame * CFrame.new(-242.799, -0.517, -128.892)

This is happening because the Position property is a Vector3, but you're trying to add a CFrame to it, which does not work. Instead, we use the CFrame property, which, as the name implies, is a CFrame.

EDIT: I also noticed that you used `game.Players.Player'. This will work while testing in studio, but online it will not. Instead, ClickDetector.MouseClick has an argument, which is the player who clicked the button. Therefore, we should change the first line to this:

script.Parent.ClickDetector.MouseClick:connect(function(PlayerWhoClicked)

and the second to this:

if PlayerWhoClicked.userId == 613323 or PlayerWhoClicked.userId ==  game.CreatorId then

Finally, notice that I added some extra code after the or. This is necessary because otherwise it would be interpreted like this:

If the value of the player's ID is equal to 613323 or the value of game.CreatorId is not nil or false, do X

But we want it like this:

If the value of the player's ID is equal to 613323 or the value of the player's id is equal to game.CreatorId, do X

DOUBLE EDIT: Again, you're using game.Workspace.Player. For what I'm assuming is the intended effect, replace that with PlayerWhoClicked.Character. It's happening because the player is only called Player when in studio. Online, it's the player's username.

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