So I’ve got this script (see below) and I’d like to know how to make the script start running as soon as the game starts. It appears that as of now it starts when each respective player joins. Can anyone help me out?
Script
while true do
wait(60)
script.Parent.Fade_Script.Disabled = false
script.Parent.Sword_Spin_Script.Disabled = false
wait(7.5)
end
Leaving your script as it is should (in theory) run as soon as the server is created.
Roblox creates a server for an experience whenever a player enters the game and there are no available servers, so the script will run as soon as a player creates a server. Looking at your script, It shouldn’t restart if another player joins, where did you place the script?
In that case it should be fine? You are using a while true loop, so the script will keep repeating itself after it finished the loop, beside that it should run as soon as a new server is created.
Well that’s what I thought, however, I tested this in-game and that wasn’t the case. I joined the server (initiating the script) and my cousin joined around 20 seconds later. The script functioned as it should for me, but it was delayed for my cousin (around 20 seconds delayed).
Hang on, just realized that you were viewing the wrong script haha. So sorry for the wasted time friend. This is the script that is causing all of the trouble (see below). It is a LocalScript located in ScreenGui.
while true do
wait(60)
script.Parent.Fade_Script.Disabled = false
script.Parent.Sword_Spin_Script.Disabled = false
wait(7.5)
end
this is a local script therefore it will start the moment a player joins and only viewable in their perspective so it won’t be globally present to everyone else
If it’s a Local Script, it will run on the client, meaning it won’t run at the same interval for everyone. If you want the GUI to appear the same on everyone, you could use a Remote Event with FireAllClients() or simply makeit a server script.
So I can just switch the script to a regular script and it’ll function as I intended, correct? Meaning it’ll begin as soon as the server is created rather than when each respective player joins.
The script will run on the server, so an issue you might have is that players who joined 60 seconds after the server’s creation won’t have to wait for the Fade & Sword Spin scripts to enable, you could fix this using a PlayerAdded function and twisting a bit how the Sword Spin, etc. script works.
If you make a server script, it should go like this.
Server creates itself → Server script starts the wait(60) loop → Player 1 joins → 60 seconds later, the Fade Script enables and plays → Player 2 joins → Player 2 joined too late, so he won’t see the Fade Script for the firs time. He has to wait for the loop to restart to see the Fade Script
Simple solution, if the Fade Script is just supposed to mark a transition from the old map to the new map, you could use a Remote Event so when the map changes, you fire the remotes to all clients and create a Fade effect on a Local Script.
Oh ok. But Player 2’s timing won’t be off, and on the next go around (and from then on), they will both view the Fade Script at the same time, correct?