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

Buttons no longer can be bought due to me moving of leaderstats from player to ServerScriptservice?

Asked by 2 years ago

The code below no longer works as I added a autosave feature in serverscriptservice, and using the player allows for people to get infinite money using hacks.

local sound = game.workspace.Money
local cost = 0
local touchedalready = 0
local button1bought = false
script.Parent.Touched:Connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) then
        local ServerScriptService = game:GetService("ServerScriptService")
        local leaderstats = ServerScriptService:FindFirstChild("leaderstats")
    local cost = 0 
        if leaderstats then
                local MoneyValue = leaderstats:FindFirstChild("Cash")
            if MoneyValue then
                if MoneyValue.Value  >= cost and touchedalready == 0 then
                    touchedalready = 1
                    MoneyValue.Value = MoneyValue.Value - cost
                    sound:Play()
                    wait(0.01)
                    button1bought = true
                    script.Parent:Destroy()
                end
            end
        end
    end
end)

Answer this question