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

How come my script only works in studio play mode?

I've been creating an intermission script for my game and it will only work in studio play mode. It will not work with Studio Test mode or Online Play mode.

I have tried many things to try fix it but in the end, none of it ever worked. Also, I made sure filtering enabled is off so that will not effect the script. The other thing i have tried to do is change the script into a local script.

Here is the code i am using:



		wait(1.2)
	if game.Players.LocalPlayer.Value.Value == 0 then
		script.Parent.Frame.Visible = true
	end
	






if game.Workspace.Settings.Intermission.Value == 30 then
	wait(1)
	game.Workspace.Settings.Intermission.Value = 29
		script.Parent.Frame.IntermissionNumber.Text = "29"
	end
if game.Workspace.Settings.Intermission.Value == 29 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 28	
		script.Parent.Frame.IntermissionNumber.Text = "28"
end
if game.Workspace.Settings.Intermission.Value == 28 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 27
		script.Parent.Frame.IntermissionNumber.Text = "27"
end
if game.Workspace.Settings.Intermission.Value == 27 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 26
		script.Parent.Frame.IntermissionNumber.Text = "26"
end
if game.Workspace.Settings.Intermission.Value == 26 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 25
		script.Parent.Frame.IntermissionNumber.Text = "25"
end
if game.Workspace.Settings.Intermission.Value == 25 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 24
		script.Parent.Frame.IntermissionNumber.Text = "24"
end
if game.Workspace.Settings.Intermission.Value == 24 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 23
		script.Parent.Frame.IntermissionNumber.Text = "23"
end
if game.Workspace.Settings.Intermission.Value == 23 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 22
		script.Parent.Frame.IntermissionNumber.Text = "22"
end
if game.Workspace.Settings.Intermission.Value == 22 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 21
		script.Parent.Frame.IntermissionNumber.Text = "21"
end
if game.Workspace.Settings.Intermission.Value == 21 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 20
		script.Parent.Frame.IntermissionNumber.Text = "20"
end
if game.Workspace.Settings.Intermission.Value == 20 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 19
		script.Parent.Frame.IntermissionNumber.Text = "19"
end
if game.Workspace.Settings.Intermission.Value == 19 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 18
		script.Parent.Frame.IntermissionNumber.Text = "18"
end
if game.Workspace.Settings.Intermission.Value == 18 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 17
		script.Parent.Frame.IntermissionNumber.Text = "17"
end
if game.Workspace.Settings.Intermission.Value == 17 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 16
		script.Parent.Frame.IntermissionNumber.Text = "16"
end
if game.Workspace.Settings.Intermission.Value == 16 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 15
		script.Parent.Frame.IntermissionNumber.Text = "15"
end
if game.Workspace.Settings.Intermission.Value == 15 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 14
		script.Parent.Frame.IntermissionNumber.Text = "14"
end
if game.Workspace.Settings.Intermission.Value == 14 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 13
		script.Parent.Frame.IntermissionNumber.Text = "13"
end
if game.Workspace.Settings.Intermission.Value == 13 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 12
		script.Parent.Frame.IntermissionNumber.Text = "12"
end
if game.Workspace.Settings.Intermission.Value == 13 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 12
		script.Parent.Frame.IntermissionNumber.Text = "12"
end
if game.Workspace.Settings.Intermission.Value == 12 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 11
		script.Parent.Frame.IntermissionNumber.Text = "11"
end
if game.Workspace.Settings.Intermission.Value == 11 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 10
		script.Parent.Frame.IntermissionNumber.Text = "10"
end
if game.Workspace.Settings.Intermission.Value == 10 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 9
		script.Parent.Frame.IntermissionNumber.Text = "9"
end
if game.Workspace.Settings.Intermission.Value == 9 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 8
		script.Parent.Frame.IntermissionNumber.Text = "8"
end
if game.Workspace.Settings.Intermission.Value == 8 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 7
		script.Parent.Frame.IntermissionNumber.Text = "7"
end
if game.Workspace.Settings.Intermission.Value == 7 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 6
		script.Parent.Frame.IntermissionNumber.Text = "6"
end
if game.Workspace.Settings.Intermission.Value == 6 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 5
		script.Parent.Frame.IntermissionNumber.Text = "5"
end
if game.Workspace.Settings.Intermission.Value == 5 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 4
		script.Parent.Frame.IntermissionNumber.Text = "4"
end
if game.Workspace.Settings.Intermission.Value == 4 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 3
		script.Parent.Frame.IntermissionNumber.Text = "3"
end
if game.Workspace.Settings.Intermission.Value == 3 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 2
		script.Parent.Frame.IntermissionNumber.Text = "2"
end
if game.Workspace.Settings.Intermission.Value == 2 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 1
		script.Parent.Frame.IntermissionNumber.Text = "1"
end
if game.Workspace.Settings.Intermission.Value == 1 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 0
		script.Parent.Frame.IntermissionNumber.Text = "0"
end
if game.Workspace.Settings.Intermission.Value == 0 then
		wait(1)
		game.Workspace.Settings.Intermission.Value = 0
		script.Parent.Frame.IntermissionNumber.Text = "0"
end





Basically, what the script does is a count down that is global to everyone because it is using some Value's to see where the count down is at. and then it will be like that to all players in the GUI that I am using.

If you have any questions regarding the script bit that says : if game.Players.LocalPlayer.Value.Value == 0 It is basically editing a value that i imported to the player's folder in game.Players.LocalPlayer using another script.

I hope someone can help me resolve the issue in this script as I think I have covered all that I can think of that may help you to fix the problem.

1 comment

0

A little advice, it's a good programming habit to be lazy. If you are writing the same code more than once there is likely a better way to do it. In this case, a loop would work perfectly.

2 answers

✓ Accepted answer

Your script is way too long for what you're trying to do. But anyways, your problem. I would highly suggest reading this. It's an article about your exact problem. Basically, if FE is on, server scripts can't use game.Player.LocalPlayer. But that's not your problem, I don't think. Your problem is that you're using a local script to make changes to workspace. When changing things in workspace from a local script the changes remain local. In order to set up a connection between the server and the players you have to use Remote Events. Here's a link to a video about Remote Events/Functions. I would personally use a normal script to make the change if you want the changes to be global. That might mean you need to make more than one script. Oh, and here's a way of simplifying your script,

--in local script
for i = 30, 0, -1 do
    script.Parent.Frame.IntermissionNumber.Text = i
    game.Workspace.EventFolder.ChangeWorkspace.Change:FireServer()---you need to visit the links to learn about remote events
    wait(1)
end

I would help you with remote events but I don't have time. If you visit the link and still don't understand then I'll try to help you. Just comment below. Good Luck!

1 comment

0

Oh and FE stands for filtering enabled. If my answer wasn't clear, I'll gladly spend some more time on your question. Just ask. And if I helped you, please click the except answer button to the left under my name. Thank you.

If this is a local script then i suggest you to wait for character to be exist. If it is a server script then i suggest you do

while true do -- commands here -- wait(1) end

or

while Intermission.Value > 0 do --commands here -- wait(1) end

1 comment

0

Not the best answer.

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