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

Script doesn't work online but works fine in studio?[Unsolved]

How could it work in studio but not online? [EDIT] What i am trying to accomplish already works, but only in roblox studio test mode, and not when i publish it to roblox! here is my script

	wait(2)
	repeat
	wait(1)
	if workspace:findFirstChild(script.Parent.Parent.Parent.Parent.Name) then
	if script.Parent.Value == 1 and script.Parent.Parent.CamValue.Value == 1 then
	Workspace.Player.Torso.CFrame = CFrame.new(Workspace.Spawners.WhiteSpawn.Position + Vector3.new(0, 2, 0))

	elseif script.Parent.Value == 2 and script.Parent.Parent.CamValue.Value == 1 then
	Workspace.Player.Torso.CFrame = CFrame.new(Workspace.Spawners.GraySpawn.Position + Vector3.new(0, 2, 0))

	
	elseif script.Parent.Value == 3 and script.Parent.Parent.CamValue.Value == 1 then
	Workspace.Player.Torso.CFrame = CFrame.new(Workspace.Spawners.BlackSpawn.Position + Vector3.new(0, 2, 0))
	end
	end
	until script.Parent.Parent.CamValue.Value == 0

Please help!!! Thank you!!! P.S this is in starterGui so it will spawn whenever the character (re)spawns P.P.S this is in a localscript

3 comments

1

What are you trying to accomplish? This will only work ONCE for a player's character named "Player" and is un-efficient

0

That didn't work, but i did change from FindFirstChild("Player") to (script.Parent.Parent.Parent.Name)

0

yoga, I think the reason why your gettings these is because you are using LocalScripts.

2 answers

If things are inserted during the game, as it seems, use WaitForChild() instead of FindFirstChild()

2 comments

0

This script is inside of starterpack, so the script isn't there until a player is, Thanks though +1

0

Also you are searching for "Player" and unless your name is Player or Player is ingame online, then the script would break.

In studio, test mode is more lenient, meaning that Server and local scripts are technically the same. However in online mode, server and local scripts run on the server and on the client respectively. Also FilteringEnabled is activated here. Check your code is FilteringEnabled-safe and don't try to do server stuff in local scripts and don't try to do local stuff in server scripts.

RemoteFunctions and RemoteEvents are your best friends. Don't mix server and local up.

If you follow the above, you should be fine.

Hope this helps!

-DuckWick -Headmaster of Creative Developers

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