GUI isn't visible when moved to starter gui (Server sided script)

This script isn’t working for me, I want to make it so every time someone joins a gui pops up on the screen. The script I made:

ball.Touched:Connect(function(part)
	if part == goal1 then
		score(gnomeScore)
		game.ReplicatedStorage.ArsenalGui:Clone().Parent = StarterGui
		wait (5)
		game.StarterGui.ArsenalGui:Destroy()
	elseif part == goal2 then
		score(elfScore)
		game.ReplicatedStorage.SpursGui:Clone().Parent = StarterGui
		wait (5)
		game.StarterGui.SpursGui:Destroy()
	end

end)
1 Like

Hey! For this you’ll have to use a remove event as the server can’t change stuff like GUI’s for a client.
And when parenting a GUI, you have to use PlayerGui. This is because everything from StarterGui gets copied onto the PlayerGui inside of the Player.

how do i use the player gui inside of the player?

You’ll have to use a localscript for that. You can do a .Touched event in them as well.
I’d recommend putting it in either StarterPlayerScripts or in the GUI in StarterGui somewhere.

Something like this in a localscript in StarterPlayerScripts.

local player = game.Players.Localplayer -- Can only do this in a localscript
local ball = game.Workspace.ball -- Path to the ball

ball.Touched:Connect(function(part)
	if part == goal1 then
		score(gnomeScore)
		player.PlayerGui.ArsenalGui.Frame.Visible = true
		wait (5)
		player.PlayerGui.ArsenalGui.Frame.Visible = false
	elseif part == goal2 then
		score(elfScore)
		player.PlayerGui.SpursGui.Frame.Visible = true
		wait (5)
		player.PlayerGui.SpursGui.Frame.Visible = false
	end

end)

Instead of having the gui in ReplicatedStorage, I’d recommend just having them in StarterGui (PlayerGui when the game starts) and making them visible = true/false

Let me know if you have any questions!

would i put the local script in starter player scripts or starter gui?

nevermind it works in starter player scripts thanks

its a goal script, every time you score a goal the ball teleports back to the middle

You stated “every time someone joins a gui pops up on the screen.” not a goal script.

1 Like

oh my bad it was a typo by accident

1 Like