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

How do you make a part pay the price?

Asked by 3 years ago
Edited 3 years ago

local rc = 50000

local debounce = true script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Money.Value >= rc then if debounce then debounce = false if plr.leaderstats.Money.Value < 20 then return end script.Parent.Transparency = 0.5 script.Parent.CanCollide = false if rc.Value <=rc then script.Parent.Transparency= 0.15 script.Parent.CanCollide = true end end end end end)

that is my script for making players be able to go threw but i need help making it take away money.

0
Explain, you are being too vague and unconstructive. nekosiwifi 398 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

This should work! ( I know this is vague and basically just the script but i didnt really know how to answer the question without giving the script xD)

local debounce = false
local rc = 50000

script.Parent.Touched:Connect(function(hit)
    local hum = script.Parent:FindFirstChild("Humanoid")
    if hum then
        if debounce == false then
            debounce = true
            local player = game.Players:WaitForChild(hum.Parent.Name)
            player.leaderstats.Money.Value = player.leaderstats.Money.Value - rc

            script.Parent.Transparency = 0.5
            wait(0.5)
            script.Parent.Transparency = 0
            debounce = false
        else
            return
        end
    end
end)
0
didn't work dabberpro1 -5 — 3y
Ad

Answer this question