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

for alphawolvess ??/

game.Players.PlayerAdded:connect(function(Player)
	if game:GetService("GamePassService"):PlayerHasPass(Player, 000) then
			game.ReplicatedStorage.Tool1:Clone().Parent = Player.StarterGear
			
	elseif game:GetService("GamePassService"):PlayerHasPass(Player, 000) then
			game.ReplicatedStorage.Tool2:Clone().Parent = Player.StarterGear
			
	elseif game:GetService("GamePassService"):PlayerHasPass(Player, 000) then
			game.ReplicatedStorage.Tool3:Clone().Parent = Player.StarterGear
	end
end)

2 answers

First I'll just tell you I don't script the same way you do, I prefer to not connect my events with a function above it.

Anyway, here is the script and look at commenting for explanations. The script bellow is on the basis of ROBLOX wiki.

local passId = 000 --ID Here
local passId2 = 0000 --Here too
local passId3 = 00000 -- Annnnd here

function isAuthenticated(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end
function isAuthenticated2(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId2)
end
function isAuthenticated3(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId3)
end
 
game.Players.PlayerAdded:connect(function(plr) -- plr = the added player
    if isAuthenticated(plr) then -- Seeing if they have the Pass
		game.ReplicatedStorage.RocketLauncher:Clone().Parent = Player.Backpack -- You should know this, you added it after all.
	end
	    if isAuthenticated2(plr) then -- Seeing if they have the Pass
		--Code Here
	end
	    if isAuthenticated3(plr) then -- Seeing if they have the Pass
		-- Code here
	end
end)

This will only give the player the rocket launcher once, along with other things for 2 and 3, depending on what you add.

I believe the problem may just be that the backpack is not yet loaded, as there doesn't seem to be any problem with the code.

I'd say try changing line 3 to:

game.ReplicatedStorage.RocketLauncher:Clone().Parent = Player:WaitForChild'Backpack'

1 comment

0

this is a good diea my praises

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