Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

VIP SurfaceGUI wont dissappear to gamepass holders?

Asked by 7 years ago

I have a SurfaceGUI that blocks a staircase, when a player without a pass walks through it, it respawns them, when they do have the pass it leaves them alone. Although I'm confused, I have a script that in my eyes should be vanishing the SurfaceGUI once the player has the pass for them. This is what the surfaceGUI looks like; http://prntscr.com/fxrx3e. The "Buy Now" script works, that's fine but the disappearing script won't. Please note that the surfaceGUI is Adorned to the block from StarterGUI.

This is the code that is supposed to take the GUI away once the player has a pass, it is in Normal Script format;

01local clone = game.StarterGui.VIPBlockGUI:Clone()
02local id = 924277735
03 
04game.Players.PlayerAdded:connect(function(player)
05if game:GetService("GamePassService"):PlayerHasPass(player, id) then
06print("player has the gamepass :O")
07else
08print("player doesn't have the gamepass :(")
09clone.Parent = player.PlayerGui
10end
11end)

If you're wondering, this is the script for the Prompt, this is in LocalScript format.

1local gamepass = 924277735
2local player = game.Players.LocalPlayer
3 
4script.Parent.MouseButton1Click:connect(function()
5    game:GetService("MarketplaceService"):PromptPurchase(player, gamepass)
6end)

This is how it looks in studio; http://prntscr.com/fxrzfi. Please get back to me as soon as you can find a solution!

1 answer

Log in to vote
0
Answered by
blowup999 659 Moderation Voter
7 years ago

1st. FilteringEnabled should be on to hide it 2nd. Just make the SurfaceGui a child of the part in the server and not in StarterGui, because the only reason it's showing the GUI is because the Adornee is set 3rd. Try these scripts

ServerScript

01local showGui = Instance.new("RemoteEvent", game.ReplicatedStorage)
02showGui.Name = "ShowVIPGui"
03local clone = game.StarterGui.VIPBlockGUI:Clone()
04local id = 924277735
05 
06game.Players.PlayerAdded:connect(function(player)
07    if game:GetService("GamePassService"):PlayerHasPass(player, id) then
08        showGui:FireClient(player, true)
09    else
10        showGui:FireClient(player, false)
11    end
12end)

LocalScript - Child of Workspace > Part > VIPBlockGUI

01local gamepass = 924277735
02local player = game.Players.LocalPlayer
03local showGui = game.ReplicatedStorage:WaitForChild("ShowVIPGui")
04showGui.OnClientEvent:connect(function(bool)
05    if bool then
06        script.Parent:Destroy()
07    else
08        script.Parent.MouseButton1Click:connect(function()
09            game:GetService("MarketplaceService"):PromptPurchase(player, gamepass)
10        end)
11 
12    end
13end)
0
Tell me if you're still having a problem blowup999 659 — 7y
0
No, I havent removed any scripts. It hasnt worked. :( MachoPiggies 526 — 7y
Ad

Answer this question