Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a tool model gamepass?

This is what the tool gamepass is like: When the gamepass is bought, the player that owns it owns a tool model (not ROBLOX gear) in the game.

This is the script that I tried:

if game:GetService('GamePassService'):PlayerHasPass() then
	game.ServerStorage.VoidSword:Clone
end

I know, there are many things wrong but this is my first time making a scripted game.

1 answer

✓ Accepted answer

**Problem: **

You seemed to not fill in the parameters of the :PlayerHasPass() . I also don't know how you want the script to give the player the tool whether it be upon joining or not so I did that. You also seem to be doing the cloning process wrong.

Solution:

I just added the parameters in their rightful place and added a PlayerAdded event. I fixed your cloning problem.

Code:

local id = 0000000 --Change this to the gamepass id you want
 
game.Players.PlayerAdded:connect(function(player)
    if Game:GetService("GamePassService"):PlayerHasPass(player, id) then --Added the Parameters 
	local clone =  game.ServerStorage.VoidSword:Clone() -- You need the parenthesis and to determine where it will be parented to
	clone.Parent = player:WaitForChild("Backpack") --In this game the player's Backpack
        print(player.Name .. " has the game pass!")
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

If you have questions don't be afraid to ask and I will be glad to answer. If this helped you don't forget to accept my answer.

4 comments

0

Thanks for the solution!

0

No problem

0

The script worked when the player joined the game, but when the player dies, the tool doesn't get cloned into the player's inventory again

0

How do I make the same code except use a different tool?

This discussion is preserved as it was. New answers, comments, and votes are closed.