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
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
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
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