My scripts don’t always detect the gamepasses and set their BoolValues to true if the players owns the gamepass.
My game adds a folder to each player that joins, named “Gamepasses”. The folder has two BoolValues in it named VIP, and DropChance. These scripts set those values to true if the player owns the gamepasses, and the VIP adds an in game chat tag. For some reason, the values of “VIP” and “DropChance” sometimes don’t get set to true, as if the script isn’t detecting the gamepass somehow, which leads me to the question of how I can fix this? Also the drop chance and vip scripts do work, but I just need the values of “VIP” and “DropChance” to actually get set to true if the player owns the correct gamepasses.
I looked for solutions, but couldn’t find exactly what I was looking for, as I’m more unsure of what the problem is with my script. I’ve already tried adding a wait on line 5, such as player:WaitForChild(“Gamepasses”) which doesn’t solve the problem.
Here are in game screen shots
https://gyazo.com/07bd3cf6e670571dbff8012896e40af1
https://gyazo.com/614d3826d5b736cb9e28e4c914b92b16
I’m the owner of the game, so I do have both gamepasses, but sometimes they just don’t get set to true.
Both of these scripts are in ServerScriptService
- The Set VIP to True Script, ignore the code past line 5, that already works. -
local gamepassId = 17790932
local service = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
player.Gamepasses.VIP.Value = true
local tags = {
{
TagText = "👑VIP",
TagColor = Color3.fromRGB(255, 255, 0)
}
}
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local speaker = nil
while speaker == nil do
speaker = ChatService:GetSpeaker(player.Name)
if speaker ~= nil then break end
wait(0.01)
end
speaker:SetExtraData("Tags",tags)
speaker:SetExtraData("ChatColor",Color3.fromRGB(255, 255, 0))
end
end)
- The Set Drop Chance to True Script -
local gamepassId = 17790571
local service = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
player.Gamepasses.DropChance.Value = true
end
end)