How would I call a function from another script?

Hello I am making a round end in my game and well I need a script that checks if all players died and then does the end_game() function instead of putting that in every line. can someone tell me how can i call a function using another script thank you.

The Function:

function end_game()
	wait()	
	wait(1)
	script.GameMusic:Stop()
	script.GameMusicTwo:Stop()
	script.TankMusic:Stop()
	script.TankMusic2:Stop()
	script.ElevatorMusic:Stop()
	script.LobbyMusic:Stop()
	script.GameMusicAmbient:Stop()
	Text = "You have failed."
	script.Scream3:Play()
	game.ReplicatedStorage.TextEvent:FireAllClients(Text)
	wait(5)
	print("Game is resetting...")
end
2 Likes

The best bet here would be a module script. It allows functions to be called from other scripts.

https://education.roblox.com/en-us/resources/intro-to-module-scripts

4 Likes

For those who are facing the same problem - the link above is outdated, refer to this. Good luck!

1 Like