So.. my friend helped my make this gamepass item randomizer... There are multiple scripts that has the same thing like this to randomize it. Every time I play a game I spawn with that weapon, then each time I die... I can't seem to change the weapon some how each time I reset. This script is really similar to my badge too and it does randomizes sometimes. IDK if it's just RNG being a butt, or if it's an error I'm having.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 11480688
function onPlayerSpawned(player)
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
print("Has Game Pass for Gun")
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true and game.Workspace:WaitForChild(player.Name):WaitForChild("5").Value == "" then
game.Workspace:WaitForChild(player.Name):WaitForChild("5").Value = "Greatsword"
wait(.4)
game.Lighting.GamepassFolder.Greatsword:clone().Parent = player.Backpack
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
onPlayerSpawned(player)
end)
end)
Players.CharacterAdded:Connect(onPlayerSpawned)

1 comment
Well, there's no randomize section in your code.