Hello i need help for a script , i want remove the gui forever after purchase with the leaderstats .
The purpose of the script is that if the player has[ > x value] in the leaderstats then it delet the gui forever
but that doesn’t work someone can help me?
Script here :
Keys = player.leaderstats.Keys
Maps = player.leaderstats.Maps
KeyPrice = 1
function buy()
if Keys.Value >= KeyPrice then
Keys.Value = Keys.Value - KeyPrice
script.Parent.Parent.Parent.Frame.Visible = false
Maps.Value = Maps.Value + 1
if Maps.Value < 0 then
script.Parent:Destroy()
end
end
end
script.Parent.MouseButton1Down:connect(buy)
If there isn’t something important that needs to change when the ScreenGui resets, you can disable ResetOnSpawn, this will make the ScreenGui not change on reset.
If there is something important, you can check again if it should be deleted
local Keys = player.leaderstats.Keys
local Maps = player.leaderstats.Maps
local KeyPrice = 1
local function Remove()
if Keys.Value >= KeyPrice and Maps.Value < 0 then
script.Parent:Destroy()
end
end
local function buy()
if Keys.Value >= KeyPrice then
Keys.Value -= KeyPrice
script.Parent.Parent.Parent.Frame.Visible = false
Maps.Value += 1
Remove()
end
end
Remove()
script.Parent.MouseButton1Down:Connect(buy)