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

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

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

2 comments

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

3 answers

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

5 comments

0

thanks but it is already a normal script in Workspace

0

But what is the main purpose of your script , a Minigame ?

0

If you just want to teleport, you can simply add the Touched function.

0

yes it is sort of a minigame

0

erm.......

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

1 comment

0

nvm the wait part, i didnt see the "wait(25)"

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

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