Gui Not Dissapearing?

I’m new to scripting and i made a script that should make the Gui invisible but it just won’t work.

-Here’s The Script

local finishLine = game.Workspace.FinishLine

finishLine.Touched:Connect(function()
game.ServerScriptService.Counter.Disabled = true
game.StarterGui.Counter.Frame.Visible = false
game.StarterGui.Counter.Frame2.Visible = false
game.StarterGui.Counter.TextLabel.Visible = false
game.StarterGui.Counter.TextLabel.Script.Disabled = true

end)

I have a few questions to help diagnose the issue:

  • Are you using a Script or a LocalScript?
  • Where is this code located in the explorer?

Another thing to note is that when editing the player’s GUIs, you should be using PlayerGui, not ScreenGui, which is a common mistake (one that I used to make too).

Also, what exactly are you trying to achieve? Do you want the timer to go away on everyones screen when one player reaches the finish line? Or maybe, the timer only goes away once the individual player reaches the end?

For the latter, you can try using a LocalScript like this, under StarterPlayerStarterPlayerScripts:

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

local finishLine = workspace:WaitForChild("FinishLine")
local counter = playerGui:WaitForChild("Counter")

local function onTouched(hit)
    if hit.Parent and not hit.Parent:FindFirstChild("Humanoid") then
        return
    end
    
    local playerHit = Players:GetPlayerFromCharacter(hit.Parent)
    if playerHit ~= player then
        return
    end
    
    counter.Frame.Visible = false
    counter.Frame2.Visible = false
    counter.TextLabel.Visible = false
end

-- Events
finishedLine.Touched:Connect(onTouched)

I’m using a script and its located under ServerScriptService

nvm, i got it, thanks for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.