So I have my screen gui here and inside is my script, and it looks like this:
player = script.Parent.Parent.Parent backpack = player.Backpack function chooseClass(class) for i, v in pairs(backpack:GetChildren()) do v:remove() end for i, v in pairs(class:GetChildren()) do if v:IsA("Tool") then v:clone().Parent = backpack elseif v:IsA("HopperBin") then v:clone().Parent = backpack end end script.Parent.Main.Visible = false script.Parent.Title.Visible = false end function onHumanoidDied(humanoid, player) script.Parent.Main.Visible = true script.Parent.Title.Visible = true end for i, v in pairs(script.Parent.Main:GetChildren()) do v.MouseButton1Up:connect(function () chooseClass(v) end) end
And then there is also a frame inside the screen gui with text buttons and tool inside them.
What I need is a feature where one of the buttons is connected to a gamepass and if you own the gamepass you get the tools inside it. Please help me create a script and tell me where to place it.
I have found a simple way to check for gamepasses by using a function that returns a boolean value. You can use it with an if statement.
--Place the function at the top of your script function HasPass(plr, id) return game.GamePassService:PlayerHasPass(plr, id) end --Place this if statement where you want it and have code in it like so... if HasPass(player, GAMEPASSIDHERE) then --Replace GAMEPASSIDHERE with the Gamepass ID --Code goes here end
I'm assuming you want to place the if statement at line 24, with line 24's code in the if statement. If I am mistaken then let me know and I'll try to help you in the best way I can!
Did this help you? Accept my answer so we can both get reputation!