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

Why Does my script work in Roblox Studio testing but not in a Roblox server when I publish it?

Asked by 7 years ago

I am new to making scripts and this is my first time making a game in Roblox I have tested this script in the test feature in Roblox Studio and it worked fine, however I tried publishing it to Roblox and it won't work. This is a teleport script BTW. Can some one tell me what I did wrong or how to fix it?

function tele2()
    local torso = game.Players.LocalPlayer.Character.UpperTorso
    torso.CFrame = game.Workspace.telespawn.CFrame
end

function tele1()
    local torso = game.Players.LocalPlayer.Character.UpperTorso
    torso.CFrame = game.Workspace.tele1.CFrame
end

while true do
    wait(25)
    tele1()
    wait(133)
    tele2()
end
0
Chances are you're using a server script, or you're using a local script wrongfully located. Here's a blog article I wrote a while back on Common Mistakes https://scriptinghelpers.org/blog/common-mistakes M39a9am3R 3210 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I do not know how script works then ...

In case a LocalScript you can add a simple wait() at start of script.

If it is a normal script that is not in Workspace you will have to move it to the workpace to start working,But this would have to modify the script

0
thanks but it is already a normal script in Workspace PlzDontB4nMe 0 — 7y
0
But what is the main purpose of your script , a Minigame ? Rodrigo2003 76 — 7y
0
If you just want to teleport, you can simply add the Touched function. Rodrigo2003 76 — 7y
0
yes it is sort of a minigame PlzDontB4nMe 0 — 7y
0
erm....... NeonProfile 111 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

So.. You said In Workspace....... Right? In Workspace, that is not really a place where you would like to use

game.Player.LocalPlayer

The Place You Might want to use it is in StarterPack Or ScreenGui. Where It Can Find Which "LocalPlayer" you're talking about, however, Also, To Make Sure You Dont Cause Your Game To Crash when there are more people in your game, you must add a wait(0.1) or wait() to wait until its created and you're not working on a nil value.

Baiiiii

0
nvm the wait part, i didnt see the "wait(25)" NeonProfile 111 — 7y
Log in to vote
0
Answered by 7 years ago

The reason it isn't working because when you make variables you need to add a WaitForChild function

I will fix the script entirely for you

function tele2() local torso = game.Players.LocalPlayer:WaitForChild("Character"):WaitForChild("UpperTorso") torso.CFrame = game.Workspace.telespawn.CFrame end

function tele1() local torso = game.Players.LocalPlayer:WaitForChild("Character"):WaitForChild("UpperTorso") torso.CFrame = game.Workspace.tele1.CFrame end

while true do wait(25) tele1() wait(133) tele2() end

Answer this question