Here’s the script
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local ScreenGUI = Player.PlayerGui
local StarterScreen = ScreenGUI.Starterscreen
local Team = Player.Team
repeat task.wait() until StarterScreen.nil --Assume this(nil) destroy or destroying
print("started")
local newHighlight = Instance.new("Highlight")
newHighlight.DepthMode = Enum.HighlightDepthMode.Occluded
newHighlight.OutlineColor = Player.TeamColor.Color
newHighlight.Parent = Character
end)
end)
Ok so what i want to make is for the script to wait until the Starterscreen get deleted then it can continue BUT if i replaced the nil with .destroying the it would already tiggered before the Starterscreen get deleted but if replaced it with :Destroy then it would immediatly destroy the screen gui somehow
The Full Script :
(Client)
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteFunction")
local Camera = workspace.CurrentCamera
local CameraObject = game.Workspace:WaitForChild("CameraJoin")
local ScreenGUI = script.Parent
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local TeamBlue = script.Parent.Blue --The button
local TeamRed = script.Parent.Red --The Button
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = CameraObject
Camera.CFrame = CameraObject.CFrame
TeamRed.MouseButton1Click:Connect(function()
local Red = Color3.fromRGB(255,0,0)
RemoteEvent:InvokeServer(Red, Character)
--Camera.CFrame = Camera.CFrame * CFrame.fromOrientation(math.rad(-19),math.rad(85), 0)
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = Humanoid
Camera.CFrame = CFrame.fromOrientation(math.rad(-20),math.rad(90), 0)
ScreenGUI:Destroy()
end)
TeamBlue.MouseButton1Click:Connect(function()
local Blue = Color3.fromRGB(0,0,255)
RemoteEvent:InvokeServer(Blue, Character)
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = Humanoid
Camera.CFrame = CFrame.fromOrientation(math.rad(-20),math.rad(-90), 0)
ScreenGUI:Destroy()
end)
(Server)
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteFunction")
local RedSpawn = workspace.RedBase.RedSpawn
local BlueSpawn = workspace.BlueBase.BlueSpawn
Remote.OnServerInvoke = function(player, colour, character)
if colour == Color3.fromRGB(255,0,0) then
local red = game.Teams.Red
player.Team = red
character:PivotTo(RedSpawn.CFrame)
elseif colour == Color3.fromRGB(0,0,255) then
local blue = game.Teams.Blue
player.Team = blue
character:PivotTo(BlueSpawn.CFrame)
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local ScreenGUI = Player.PlayerGui
local StarterScreen = ScreenGUI.Starterscreen
local Team = Player.Team
repeat task.wait() until nil
print("started")
local newHighlight = Instance.new("Highlight")
newHighlight.DepthMode = Enum.HighlightDepthMode.Occluded
newHighlight.OutlineColor = Player.TeamColor.Color
newHighlight.Parent = Character
end)
end)