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

How to make a model, a game pass tool that is buyable to use ingame?

Asked by 6 years ago

I'm making a game, and I wanted to make a game pass for it. I created a part and made a keycard shape and then watched a few videos to learn how to do it. None of them worked. Basically what I've done is I've saved the model of my keycard, and I've also created the game pass. I just need help making a script that works and does the following:

Checks if the game pass has been bought by a player joining the game. If it has, then give the tool to the player. If not then just do nothing and they don't get the tool.

Hopefully, someone has a solution for this because I'm new to scripting.

1 answer

Log in to vote
0
Answered by 6 years ago

create a Folder inside of game.ServerStorage named "PassTools"

put all the tools you want to give to the player when he joins the server

put this script in ServerScriptService

local passId = 0 -- replace with pass id

local toolFolder = game.ServerStorage.PassTools
local passServ = game:GetService("GamePassService")

function GiveToolsToPlayer(player)
    if passServ:PlayerHasPass(player, passId) then
        player:WaitForChild("StarterGear")
        player:WaitForChild("Backpack")

        for _,tool in pairs(toolFolder:GetChildren()) do
            tool:Clone().Parent = player.StarterGear
            tool:Clone().Parent = player.Backpack
        end
    end
end
game.Players.PlayerAdded:connect(onPlayerAdded)
0
This is the error message it gave me 20:57:15.153 - Attempt to connect failed: Passed value is not a function 20:57:15.153 - Stack Begin 20:57:15.154 - Script 'ServerScriptService.Script', Line 17 20:57:15.155 - Stack End 20:57:15.155 - attempt to call a nil value MathinatorMatthew -6 — 6y
0
Is game.ServerStorage just the ServerStorage? MathinatorMatthew -6 — 6y
Ad

Answer this question