So far this is my script for the part. It works just fine but I'm trying to add a 2x points gamepass.
local part = script.Parent local canGet = true local function onTouch(otherPart) local humanoid = otherPart.Parent:FindFirstChild('Humanoid') if humanoid then local player = game.Players:FindFirstChild(otherPart.Parent.Name) if player and canGet then canGet = false player.leaderstats.Points.Value = player.leaderstats.Points.Value + 30 wait(60) -- Cooldown between each point increase canGet = true end end end part.Touched:Connect(onTouch)
You can use MarketplaceService:UserOwnsGamePassAsync(), which returns a bool depending on if the user owns the game pass. You can use that bool to determine whether to give 30 or 60 points.
By the way, I recommend using +=
so you do not have to type the path all over again.
player.leaderstats.Points.Value += 30
Also, you can remove the Humanoid check as it is unnecessary.
My script looked like this by the way.
local part = script.Parent local canGet = true local player = game.Players.LocalPlayer local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamepassAsnyc(player.UserId, 15971605) -- Gamepass Id local function onTouch(otherPart) local player = game.Players:FindFirstChild(otherPart.Parent.Name) if player and canGet then if ownsGamepass then canGet = false player.leaderstats.Points.Value += 60 wait(60) -- Cooldown between each point increase canGet = true end else canGet = false player.leaderstats.Points.Value += 30 wait(60) -- Cooldown between each point increase canGet = true end end part.Touched:Connect(onTouch)