So, as my question stated, how do I change this script to refer to the Gui without having to place the Gui in the Script to run?
function died (playerDied, random)
script.ScreenGui:Clone().Parent = random.PlayerGui
local player = game:GetService("Players")
player.CharacterAutoLoads = false
I’m not entirely sure what you mean…
Do you mean something like this?
Or something else?
Yeah, the script is in ServerScriptService while the Gui is in StarterPlayer so I need the Gui in the StarterPlayer to show up since this script requires the Gui to be in the script.
Inside of your PlayerAdded, you should be able to do this:
player.CharacterAdded function will never run the first time, because you’re yielding for your
CharacterAdded:Wait() Event first, before detecting an added Character the next time
There’s a lot to change with this script here, but I won’t get into all the main details
If you wanna refer to the Gui, add more variables to your script & consider moving your script somewhere else, like
local RS = game:GetService("ReplicatedStorage")
local Plrs = game:GetService("Players")
local ScreenGui = RS:WaitForChild("ScreenGui")
local function PlayerDied(Plr)
local PlrGui = Plr:WaitForChild("PlayerGui")
local UIClone = ScreenGui:Clone()
UIClone.Parent = PlrGui
Plrs.CharacterAutoLoads = false -- Keep in mind that this will toggle for EVERY player in the server
local function PlayerAdded(Plr)
local Hum = Char:WaitForChild("Humanoid")
Btw, when I place that in place of the script, it underlines the last couple lines and fives an error.
What is the error?
Can you try again? I forgot to add a couple more things there, mb
So I put it in again and it underlines RS for some reason.
How is it underlining though? Did you copy & paste the entire script?
You didn’t add the
RS line here:
Alright, that seemed to work, but it won’t run because this script is not working.
local Market = game:GetService("MarketplaceService")
Market.ProcessReciept = function(reciept)
if reciept.ProductId == 1306306067 then
local player = game.Players:GetPlayerByUserId(reciept.PlayerId)
The whole idea is to give the player a Gui when they die so that they can pay to respawn at the last checkpoint or they just can reset to the start.