How Do you Make A Gamepass Give A Tool/PetTool ?
Ive been trying for hours but still cant make it work.
How Do you Make A Gamepass Give A Tool/PetTool ?
Ive been trying for hours but still cant make it work.
Have you tried going on Youtube or searching through the forum?
i’m prett ysure there’s tutorials for it.
Upon a player joining, use :UserOwnsGamepassAsync().
local gamepassId = 0 --change to gamepassid
local players = game:GetService("Players")
local mps = game:GetService("MarketplaceService")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if mps:UserOwnsGamePassAsync(player.UserId, gamepassId) then --user owns gamepass
--do code
end
end)
end)
This is relatively simple, you just need the user ID of the player of which you want to check if they own a particular gamepass or not and the ID of that gamepass. The function used in the above script is:
https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/UserOwnsGamePassAsync
This script checks whenever the “CharacterAdded” event is fired whether or not the user owns a particular gamepass, from there you can decided whether or not to award the user with an item, additional stats, a custom character morph etc.
Here is the Basic Version. pls note that it could have still the Backpack bug. I forgot how to fix it and i have bo time right now to go snd check in my scripts.
Code:
local gamepassId = 0 --change to gamepassid
local players = game:GetService("Players")
local mps = game:GetService("MarketplaceService")
local player = players.Localplayer
local tool = game.ReplicatedStorage.toolname --put the destination of your Tool in here
players.PlayerAdded:Connect(function(player)
if mps:UserOwnsGamePassAsync(player.UserId, gamepassId) then --user owns gamepass
local toolCloned = tool:Clone()
toolCloned.Parent = player.Backpack --I think i mademistake here, idk anymore the Backpack parent problem, but could be right.
end
end)