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

How do I make a Obby for Cash? - Zednov's Tycoon Kit

Asked by 5 years ago

Trying to make a button that when the Player completes the obby they can receive say like a 1000 cash from touching a part or something. This needs to some how work with Zednov's Tycoon Kit also.

1 answer

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

Firstly, I would like to say that ScriptingHelpers is not a website for requesting scripts. Requesting scripts is against the guidelines of ScriptingHelpers. Anyways, on to actually making the script. In ServerScriptService, create a new script and name it "Leaderstats".

-- Leaderstats
game.Players.PlayerAdded:Connect(function(plr)
    local leaderstats = Instance.new("IntValue") -- Container for leaderboard values
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr

    local cash = Instance.new("IntValue")
    cash.Name = "Cash"
    cash.Value = 0
    cash.Parent = leaderstats
end)

That script will create a leaderboard. "leaderstats" is a container for values that are displayed on the leaderboard, and "Cash" will be the value displayed. Create a new script in ServerScriptService called "CashScript".

-- CashScript
local debounce = false -- Cooldown
local part = workspace.Part -- Change to the part you want to give cash
local cooldownTime = 1

part.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
    if humanoid and not debounce then -- Checking to see if this is something alive and not on a cooldown
        local playerName = humanoid.Parent.Name -- Getting the name of the character
        local player = game.Players[playerName] -- Finding out if this is a player
        if player then
            player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10
            debounce = true -- Makes a cooldown
            wait(cooldownTime)
            debounce = false
        end
    end
end)

I hope this helped. Anyways, please refrain from requesting scripts.

0
Thanks! My bad I haven't read the guidelines very closely, but I won't make the mistake again :) Thanks for the help though!! businessman32246 2 — 5y
0
By the way did you mean ServerScriptService? Because ServerScriptStorage is not a thing I think? Idk I'm just gonna take a guess and put these scripts in ServerScriptService :) businessman32246 2 — 5y
0
I meant ServerScriptService, not ServerScriptStorage. :P SaltyIceberg 81 — 5y
Ad

Answer this question