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)
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.
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