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

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

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

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)

2 comments

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

0

Is game.ServerStorage just the ServerStorage?

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