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

Teleportation Script acting fine in Studio, weird in Game. Any Help?

So it's working fine in Roblox Studio, but weird in the game. What's suppose to happen, is that the script waits until a TextLabel changes, and then gets teleported to a map. After this, it waits until the TextLabel changes AGAIN, and then teleports back. This works fine in Studio, but once I go into my game, I automatically spawn in the map. This is super weird. (By the way, this is a script in SSS.)

Heres the Script: (Sorry for the long tables)

game.Players.PlayerAdded:Connect(function(player)
	while true do
	local Tab = {CFrame.new(-907, 5.4, -307); CFrame.new(-708, 73.4, -338); CFrame.new(-719, 73.4, -243); CFrame.new(-696, 55.4, -288); CFrame.new(-747, 6, -279); CFrame.new(-650, 5, -294); CFrame.new(-712, 8.6, -193); CFrame.new(-903, 5, -425); CFrame.new(-902, 8.6, -176); CFrame.new(-679, 55.4, -366); CFrame.new(-768, 60.2, -394); CFrame.new(-673, 38.6, -373); CFrame.new(-726, 38.6, -253); CFrame.new(-727, 55.4, -330)}
	local locationselected = Tab[math.random(1, #Tab)]
	local Spawnplates = {CFrame.new(19.511, 18.27, -42.511); CFrame.new(-31.86, 18.069, -18.085); CFrame.new(36.297, 19.375, -23.067); CFrame.new(-23.937, 18.17, -34.292); CFrame.new(-7.526, 18.27, -45.252); CFrame.new(-31.86, 18.069, -18.085); CFrame.new(37.096, 18.471, 9.724); CFrame.new(-35.261, 18.471, 2.364); CFrame.new(19.511, 18.27, -42.511)}
	local spawnselected = Spawnplates[math.random(1, #Spawnplates)]
	player.PlayerGui:WaitForChild("ScreenGui").TextLabel.Changed:Connect(function()
	game.Workspace:WaitForChild(player.Name).Head.CFrame = locationselected
	end) -- This is one of the tp scripts
	player.PlayerGui:WaitForChild("ScreenGui").TextLabel.Changed:Connect(function()
	game.Workspace:WaitForChild(player.Name).Head.CFrame = spawnselected
	end) -- This is one of the tp scripts
	wait()
	end
	end)

Any help would be appreciated. (Nothing in Output/Dev Console btw)

1 answer

The serverscript cannot access the player's gui. Only localscript can. I advise you do all that in local script since the character's position can still be seen by server and client using local script. And, you can access the playergui using local script. Hope i helped!

2 comments

0

That's weird... I just fixed the issue btw. The original textlabel was set to "" so It would change to "Intermission" and send me to the map. To fix I just started it off as "Intermission". And The Server Script seems to be accessing the player's gui fine.

0

I see. Could you do me a favor and accept my answer to tell the people that this is already solved? I keep mistaking for solved things as well as others.

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