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

how to make a regen script that cost money to regen a model? [closed]

Asked by 3 years ago

basically what the title said

0
what????????????????????????????????????????????????????????????? Xapelize 2658 — 3y
0
This is not a request site... I don't know how many times i write this a day Superexperiencedguy 199 — 3y
0
" This is not a request site... I don't know how many times i write this a day" i agree AIRBORNENicuYT 20 — 3y

Closed as Too Broad by User#6546

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
PassId = 412981249 -- i randomly typed this i dont know what is this dont buy it

game:GetService("Players").PlayerAdded:Connect(function(player)
    if player -- do something or what what what
        game.MarketplaceService:PromptGamePassPurchase(player, PassId) 
        if game.MarketPlaceService:UserOwnsGamePassAsync(player,PassId) then
            local part = -- location of part
            part.Transparency = 0
            part.CanCollide = true
        end
    end
end)

I think you meant this? I don't really know what are you talking about, but this is a sample, you can ask me any questions if you are confused like me

0
no what i meant is a button that regen lets say a car and you can only do it if you have 500 cash thedukke1 9 — 3y
Ad
Log in to vote
0
Answered by
pwx 1581 Moderation Voter
3 years ago
local regenPart = script.Parent -- relocate if you want
local requiredAmount = 100 -- change this to how much you want it to cost
local Currency = 'Cash' -- change this to what your currency is called
local Players = game:GetService('Players')

regenPart.Touched:Connect(function(Hit)
    local Player = Players:GetPlayerFromCharacter(Hit.Parent)
    if Player then
        local leaderStats = Player:WaitForChild('leaderstats')
        if leaderStats[Currency].Value >= requiredAmount then
            leaderStats[Currency].Value = leaderStats[Currency].Value - requiredAmount
            -- regen stuff here
        end -- amount check
    end -- player check
end) -- onTouched