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

How to make Gamepass GUI's? [SOLVED]

Asked by 9 years ago

I know how to set the GUI's and everything but a bit confused on the scripting. Can someone explain to me in FULL detail on what to do step to step please?

Thanks if anyone helps (:

1 answer

Log in to vote
0
Answered by 9 years ago

Hello, I am not that good at explaining myself, so I will try my best. In this guide, I will help you create GUI's linked to Gamepass scripts.

In this Guide, I will be using an example of a Health Gamepass. As you go through it you can edit it into something else.

If you DO happen to do that, PM me for the coding of what you want and I will be happy to assist you.

First, what you want to do is go to StarterGUI > Insert ScreenGUI > Insert Script + Frame. Rename your Frame to Main then insert another Frame and rename that one ShopFrame. Also insert a ImageButton into your MainFrame as well.

The next you want to do is insert a Text Button. Now remember, as your doing this you have to resize and reshape the way you want your GUI's to look. I am only helping you out with the Scripting.

Now, this is where we get into the Scripting part. Inside of your Button, make the name "Shop" inside of Properties and make sure thats on the top of your ShopFrame GUI. Inside of your second Button, Insert a LocalScript [A Local Script is a script that runs on one single player by themseleves.] , rename the LocalScript to "Item".

Now, inside of this script you want to put :

local productId = PUT ID HERE
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function() 
    game:GetService("MarketplaceService"):PromptPurchase(player, productId)
end)  

After you have done that, we can now move on to the Gamepass Scripts themselves. Go to your ServerScriptService [You can as well go to Workspace, but I prefer this one to keep the scripts organized]. Insert a script, and rename it to the name you want your game pass to be, for example, lets name ours "GamePassExtraHealth".

Now, inside of that script insert this coding :

gps = game:GetService("GamePassService");

id = script:WaitForChild("GamePassID");
EH = script:WaitForChild("ExtraHealthAmount");


game.Workspace.ChildAdded:connect(function(char)
h=char:FindFirstChild("Humanoid")
if h~=nil then
plr=game.Players:FindFirstChild(char.Name)
if gps:PlayerHasPass(plr, id.Value) then
h.MaxHealth=EH.Value
h.Health=EH.Value
end
end
end)

Then after that, right click on that same script and insert two NumberValues. Rename one of them to what you are adding. In our case its "ExtraHealthAmount". Rename the other one "GamePassID".

For the +Health we want to allow the person, we can put that amount into the value of the "ExtraHealthAmount".

Now for all of this to work, this may be silly but is has happened before, you will need to create your Gamepass and insert the ID's where I told you to put them in.

PM me if you still need additional help. (:

Ad

Answer this question