#Auto Clicker for sim

1 messages · Page 1 of 1 (latest)

wise remnant
#

im trying to make it that when you buy the gamepass you can use the auto click for the simulator, it works but it doesnt save for some reason pls help

script:
``local hasBought = false

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(plr, passId, wasPurchased)
if plr == player and passId == GamepassID and wasPurchased then
hasBought = true
end
end)

if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
hasBought = true
end

button.MouseButton1Click:Connect(function()
if not hasBought then
print("ok2")
MarketplaceService:PromptGamePassPurchase(player, GamepassID)
else
if not enabled then
enabled = true
running = true
frame.BackgroundColor3 = Color3.new(0, 1, 0)

        if coinImageScript and slowClickScript then
            slowClickScript.Enabled = false
            coinImageScript.Enabled = false
        end

        startCoinLoop()
    else
        enabled = false
        running = false
        frame.BackgroundColor3 = Color3.new(1, 0, 0)

        if coinImageScript and slowClickScript then
            slowClickScript.Enabled = true
            coinImageScript.Enabled = true
        end
    end
end

end)``

Pls help me

ornate saddle
#

Gotchu bro. So here’s the deal:

Your script doesn’t save because hasBought is just a local variable, meaning it resets every time the game/server restarts or the player rejoins. You’re checking UserOwnsGamePassAsync, which is good, but you need to call that at the right time — and for the right player.

Here’s a fixed version with better structure:

#

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local GamepassID = 12345678 -- replace with your real Gamepass ID

local button = script.Parent
local frame = button.Parent
local hasBought = false
local enabled = false
local running = false

-- Scripts to disable/enable
local coinImageScript = frame:FindFirstChild("CoinImageScript")
local slowClickScript = frame:FindFirstChild("SlowClickScript")

-- Check if player already owns gamepass when GUI loads
task.spawn(function()
local success, owns = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
end)

if success and owns then
    hasBought = true
end

end)

-- Listen to when they buy it
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(plr, passId, wasPurchased)
if plr == player and passId == GamepassID and wasPurchased then
hasBought = true
end
end)

-- Button logic
button.MouseButton1Click:Connect(function()
if not hasBought then
print("Prompting purchase...")
MarketplaceService:PromptGamePassPurchase(player, GamepassID)
else
enabled = not enabled
running = enabled
frame.BackgroundColor3 = enabled and Color3.new(0, 1, 0) or Color3.new(1, 0, 0)

    if coinImageScript and slowClickScript then
        slowClickScript.Enabled = not enabled
        coinImageScript.Enabled = not enabled
    end

    if enabled then
        startCoinLoop()
    end
end

end)

wise remnant
#

ohhhhhhhhhh

#

THANK YOU SO MUCHHH

ornate saddle
#

Yep 😊

#

Np I'm just happy to help! If it works tell me!

#

And also notes: UserOwnsGamePassAsync already "saves" the purchase — you don’t need to store anything extra.
You just have to check ownership again every time the player rejoins. That’s what this line does:

#

MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)

Don’t rely on hasBought alone; always double-check with Roblox API.


Let me know if you want to add a loading spinner or something while it checks!

wise remnant
#

...

#

ik this is ai but whatever i get the bug so still thanks

ornate saddle
#

?