Need help with GUI and scripting

im making this game and i want a black screen to popup after you activate a proximity prompt and then it kicks you from the game. (its for a ending system)

You could just reference the Player parameter with the given ProximityPrompt.Triggered event, and easily get the Player’s GUI that way to slowly make the screen fade to black

i don’t know how to script thats my problem.

Bruh

Well, what we could do is define our variables (Or easily get our Objects to what we want to activate and what we don’t want to activate)

An Event in scripting is just simply something that will start when the given requirement is called for (When a player activates a ProximityPrompt, when a player joins the game, etc)

local Part = script.Parent
local Prompt = Part.ProximityPrompt

Variables are just there to easily reference, now what we can do is watch for an Event that will be fired when the Prompt is activated:

Prompt.Triggered:Connect(function(Player)

end)

The fun thing is that the Triggered event gives us the Player object as it’s parameter, so we can get the PlayerGui fairly simple that way

Next what we’d wanna do is initiate a loop inside our Event, that will slowly make the Black Screen appear (You’d need to have a UI Frame inside StarterGui) and we want to wait for every time that it’s called, otherwise it’ll just fire instantly & just literally create the fastest world record for a Player Kick

Prompt.Triggered:Connect(function(Player)
    for Loop = 1, 10 do
        Player.PlayerGui.FadeToBlack.Frame.BackgroundTransparency -= .1
        wait(.1)
    end
end)

Objects have certain properties we can use to change, for this instance though we can get the BackgroundTransparency property that’s provided by the Frame object

After we finish our fade loop, then we can go ahead & kick our player with a provided message if any:

Prompt.Triggered:Connect(function(Player)
    for Loop = 1, 10 do
        Player.PlayerGui.FadeToBlack.Frame.BackgroundTransparency -= .1
        wait(.1)
    end
    Player:Kick("Ending 30432049! You only have 30432048 more to go!")
end)

And that’s pretty much it! Just make sure to parent the script inside the Part that will trigger the Prompt, and it should work!

Full code:

local Part = script.Parent
local Prompt = Part.ProximityPrompt

Prompt.Triggered:Connect(function(Player)
    for Loop = 1, 10 do
        Player.PlayerGui.FadeToBlack.Frame.BackgroundTransparency -= .1
        wait(.1)
    end
    Player:Kick("Ending 30432049! You only have 30432048 more to go!")
end)

Maybe try brushing up on your Luau knowledge, it’d be futile for anyone to write you a full script and you not knowing how it works, I strongly recommend you are somewhat versed in Lua and Roblox Lua, here are some resources to get started: