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

How do I make gamepasses work?

I want to give a player dual illuminas when they have a gamepass. NOTE that I do not know one thing about scripts, so you have to tell me where I put the ID for the gamepass, and where I put the ID for the dual illuminas. Thanks!

2 answers

Next time please attempt to actually write the script, or at least look it up on the wiki. I will still answer this, however. (This is taken directly off the wiki)

local passId = 0000000 -- change this to your game pass ID.
 
function isAuthenticated(player) -- checks to see if the player owns your pass
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end
 
game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
        local dsw = game.ServerStorage.DualSwords:Clone()
		if plr:FindFirstChild("Backpack") then
			dsw.Parent = plr.Backpack
		end
		if plr:FindFirstChild("StarterGear") then
			dsw.Parent = plr.StarterGear
		end
    end
end)

So to make that work, you will have to get a model of the Dual Illuminas, place them into ServerStorage (Not StarterPack!) and then on line 9 you will have to change the name of the tool to DualSwords, or you could rename game.ServerStorage.DualSwords into whatever the model is called.

I hope I helped.

2 comments

0

Ok it works, but when you die the swords get lost, and I don't want them lost. See, this is for a swordfighting game so this will need some kind of loop if I am correct?

0

I edited my answer.

local passid = 168824527--CHAnge to game pass id
local tool = game.Lighting.Pistol--change to tool location in game(i.e.game.Lighting.AssaultRifle)
local GamePassService = Game:GetService('GamePassService')
game.Players.PlayerAdded:connect(function(player)
	repeat wait(0.1) until player.Backpack	
	repeat wait(0.1) until player.StarterGear
	if GamePassService:PlayerHasPass(player, passid) then
		local tool1 = tool:Clone()
		local tool2 = tool:Clone()
		tool1.Parent = player.Backpack
		tool2.Parent = player.StarterGear
	end
end)
--put ur tools in lighting and anyone who has this pass will get that tool.

1 comment

0

no losing when u die!

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