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

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

Asked by 9 years ago

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

1
What are you trying to accomplish? This will only work ONCE for a player's character named "Player" and is un-efficient alphawolvess 1784 — 9y
0
That didn't work, but i did change from FindFirstChild("Player") to (script.Parent.Parent.Parent.Name) yogipanda123 120 — 9y
0
yoga, I think the reason why your gettings these is because you are using LocalScripts. woodengop 1134 — 9y

2 answers

Log in to vote
1
Answered by
Moxeh 84
9 years ago

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

0
This script is inside of starterpack, so the script isn't there until a player is, Thanks though +1 yogipanda123 120 — 9y
0
Also you are searching for "Player" and unless your name is Player or Player is ingame online, then the script would break. Ryzox 220 — 9y
Ad
Log in to vote
0
Answered by
Elttob 15
9 years ago

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

Answer this question