Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

If a player owns a gamepass, is there a way to change the value of an Int value?

Asked by 1 year ago

recently, I've been making a game. Over time, water drains out of a tree and you have to refill it. however, I wanted to make a gamepass that gives the tree infinite water. Right now, the script refuses to work for some reason even though there is no errors. Can anyone help?

SCRIPT: local Players = game:GetService("Players") local MarketPlaceService = game:GetService("MarketplaceService") local GamepassID = 122927257

Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then script.Parent.Value = 9 end end) end)

1 answer

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

Try to make the check in a var. like this:

local success, errormsg = pcall(function()
    local bool = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
if bool then
    script.Parent.Value = 9
end
end
0
But you need to pcall() it to avoid errors. Those erros will break the script forever T3_MasterGamer 2189 — 1y
0
it checks if the bool value is even there and true but if u really need to pcall then ill post another answer mono67890 -2 — 1y
Ad

Answer this question