Player connection/variable bugging the whole script that comes after it

I wanted to make something for my game, though i run in this problem. When i try to add a player’s variable or function (game.players.playeradded:connect(function(plr) the whole script that will come after that line of code will simply not execute. I could write this differently in a local script but i tried and it worked but it only executed on studio and not the actual game no matter how i wrote the script. Back to the main problem, it doesnt give any errors, it just simply doesnt execute the script that comes afterwards (note that i paused the script at a point so i could fix this problem)
Edit: I cancelled this ending so i dont technically need a fix now, though if you still want, you can still fix this and i may get back to working on it, thanks

local Button = script.Parent
local NukeAlarm = game.Workspace.NukeEnding["Nuke Alarm"]
local NukeArriving = game.Workspace.NukeEnding.NukeArrivingSong
local Ending = game.Workspace.NukeEnding.NukeEndingSong
local Explode = game.Workspace.NukeEnding.Rocket_Explode
local Event1 = game:GetService("ReplicatedStorage").NukeWarning
local Event2 = game:GetService("ReplicatedStorage").NukeEnding
local Event3 = game:GetService("ReplicatedStorage").NukePlayerStopMoving

Button.Activated:Connect(function()
	game.Workspace["Grimace shake ending"].Interact.ProximityPrompt.Enabled = false
	game.Workspace.CLASHROYALEOMGHEHEHE.ClickDetector.MaxActivationDistance = 0
	game.Workspace["Grimace shake ending"].GrimaceShopBarrier.CanCollide = true
	game.Workspace["Pineapple on pizza ending"].Pineapple.ProximityPrompt.Enabled = false --Dont consider me crazy, that ending is just a troll lol.
	game.Workspace.NukeEnding.Barrier.CanCollide = true
	game.Workspace.NukeEnding.Barrier.Transparency = 0
	game.Workspace.NukeEnding.ClosedNukeSign.SurfaceGui.SIGN.Visible = true
	game.Workspace["Grimace shake ending"].John:Destroy()
	local anim = game.Workspace.CLASHROYALEOMGHEHEHE.Humanoid:LoadAnimation(game.Workspace.NukeEnding.Animation) --CLASHROYALEOMGHEHEHE isnt my player, its a model, just incase you though.
	anim:Play()
	anim.Looped = true
	game.Workspace.Song.Playing = false
	NukeAlarm.Playing = true
	NukeAlarm.Looped = true
	game.Lighting.NukeEndingColor.Enabled = true
	Button.Parent = game:GetService("ServerStorage")
	wait(5)
	Event1:FireClient() --I need to add a variable that gets the player in the parentesis, if i do though the code afterwards will not execute
end)

Assuming this script is a server script, button clicks that are not from ClickDetectors don’t replicate between the client and server… you need to use remotes or clickdetectors in order to make the button interaction work

In this case its a tool, and the script is working just fine even if whats going on there is a server script because i saw that server and client connect to each other and both execute the script like its supposed to. Do i still try what you said? will it fix my problem?