Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

(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

Log in to vote
0
Answered by 8 years ago

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.

Ad

Answer this question