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

Why does my script reset when another player joins the game?

This script works just fine on it's own, but when another player joins the game (while the script is running, obviously), it resets, causing the GUI to go crazy, the songs to restart, the maps to duplicate in parts, etc, etc. I have no idea of why this is happening, this is a global script, there isn't anything local in it. Please help me. :(

warning: reasonably long script below

local storage1 = game:GetService("ServerStorage")
local island = storage1.Island
local storage = game:GetService("ReplicatedStorage")
local text = storage:WaitForChild("Value")
local players = game.Players:GetChildren() 

text.Changed:connect(function()
	script.Parent.Text = text.Value
end)

while true do
	game.Workspace.elevatorMusic:Play()	
	for i= 15,1,-1 do
		text.Value = "Game starts in "..i.." seconds."
		wait(1)
	end
	game.Workspace.elevatorMusic:Stop()	
	local clone = island:Clone()
	clone.Parent = workspace
	game.Workspace.evangelion1:Play()
	if players ~= nil then 
		for i,v in pairs(players) do
   			v.Character.Torso.CFrame = game.Workspace.Island["tp1"].CFrame + Vector3.new(0,5,0)
		end
	end	
	for i= 60,1,-1 do
		text.Value = "Game ends in "..i.." seconds."
		wait(1)
	end
	if players ~= nil then 
		for i,v in pairs(players) do
   			v.Character.Torso.CFrame = game.Workspace.Spawn.thespawn.CFrame + Vector3.new(0,5,0)
		end     
	end
		game.Workspace.Island:Destroy()
		game.Workspace.evangelion1:Stop()
end

1 answer

local players = game.Players:GetChildren() 

Here is your problem. This should be.

local players = game.Players.LocalPlayer

That way each person gets moved individually.

Put this in StarterPack

1 comment

0

This makes the script work in Studio, but not in the actual ROBLOX exe.

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