yeah so there is a “VIP” value in the player and this script is making that VIP folder to true if the player purchased the pass
but when i see the value it shows false!
local function playeradded(player)
for i, v in gamepassproduct do
print("Step1")
local hasPass = false
local sucess , errormsg = pcall(function()
hasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, v.ID)
print("Step 2")
end)
if hasPass then
print("Step 3")
end
if hasPass then
print("step 4")
if v.ID == VIPid then
local vipvalue = player:WaitForChild("VIP")
vipvalue.Value = true
if vipvalue.Value == true then
print("Step 5")
end
end
end
if not sucess and hasPass then
warn(errormsg)
end
end
end
How many steps did it print? If it doesn’t print step 3, 4 and 5 then you didn’t purchase the gamepass, try after buying the gamepass fire this function again
Considering this is a VIP Pass storing that information on the player is bound to get hacked. This is something you would want secure. Even if that means calling a from a few scripts. This is a short way to get that information securely. Ideally you would only want to call this once on spawn(s).
-- server script in ServerScriptService
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local gamepassID = 123456789
function Spawned(player)
task.wait(1.1) local HasGamepass = false
local success, message = pcall(function()
HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userId, gamepassID)
end) if not success then warn(tostring(message)) return end -- shows error to warn
if HasGamepass then
-- print(true)
--
-- your vip adds
-- game.ServerStorage.Tools.Grenade2:Clone().Parent = player.Backpack
--
-- else print(false)
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
Spawned(player)
end)
end)
Hey, I looked at this script and i notice that isn’t it is same? And btw i asked for help with value of “VIP” but even this script is ok but they look the same? How it is going to protect it?
if HasGamepass then
local vipvalue = player:WaitForChild("VIP")
vipvalue.Value = true
end
“How it is going to protect it?”
This is all handled in an untouchable ServerScriptService Script. You protect it by not making available to hackers. As I said holding it in a bool on the player isn’t secure. Adding these lines blows all hope of that … Take care of your VIP adds in that script.
So this script is in serverscript and this changes the value of vip in the player adn if they have the gamepass then it will change to true but here it does not change to true and remains false!
If you would still like to use the boolvalue (Which in my eyes won’t harm as of now since its on the serverside and can only be read and not modified by exploiters) You can try this code.
Hopefully it works for you, Feel free to let me know if it doesnt!
local MarketplaceService = game:GetService("MarketplaceService")
local VIPid = "" -- Replace with your VIP game pass ID
local function playeradded(player)
for i, v in ipairs(gamepassproduct) do
print("Checking game pass:", v.ID)
local hasPass = false
local success, errorMessage = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, v.ID)
end)
if success then
print("Game pass check successful for:", v.ID)
if hasPass then
print("Player owns the game pass:", v.ID)
if v.ID == VIPid then
local vipvalue = player:FindFirstChild("VIP")
if vipvalue then
vipvalue.Value = true
if vipvalue.Value == true then
print("VIP value set to true for player:", player.Name)
end
else
warn("VIP value not found for player:", player.Name)
end
end
end
else
warn("Error checking game pass:", v.ID)
warn(errorMessage)
end
end
end
game.Players.PlayerAdded:Connect(playeradded)
if haspass then
local vipvalue = player:FindFirstChild("VIP")
if vipvalue then
vipvalue.Value = true
end
end
So here the script should change the value of vip from false to true but it does not work out and FindFirstChild also might not work because the Vip value gets added after just few seconds so that is why i added Wait for child as it waits for it to load!
local vipvalue = player:WaitForChild("VIP")
if vipvalue then
vipvalue.Value = true
if vipvalue.Value == true then
print("VIP value set to true for player:", player.Name)
end
print("Value now", vipvalue.Value)
else
warn("VIP value not found for player:", player.Name)
end
-- server script in ServerScriptService
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local gamepassID = 123456789 -- Add your ID
function Spawned(player)
task.wait(1.1) local HasGamepass = false
local success, message = pcall(function()
HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userId, gamepassID)
end) if not success then warn(tostring(message)) return end -- shows error to warn
if HasGamepass then
player:WaitForChild("leaderstats").VIP.Value = true
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
-- set up to create the bool
-- local VIP = Instance.new("BoolValue")
-- VIP.Name = "VIP" VIP.Value = false
-- VIP.Parent = player:WaitForChild("leaderstats")
Spawned(player)
end)
end)
Btw: What’s with all the !!!'s. No one here is obligated to help you at all. A bit more tact would be nice.