Still have questions? Join our Discord server and get real time help.
Log in to vote

is there a script where when i kill something i get 10 coins?

Asked by
RareBIue 133
2 months ago

Like I already have build my game but I need help on making where when I kill something it gives 10 coins.

1 answer

Log in to vote
Answered by 2 months ago

first, you need to make a leaderboard, make a script in serverscriptservice type this in

local function onPlayerJoin(player)
    local leaderstats ="Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local coins ="IntValue")
    coins.Name = "coins"
    coins.Value = 0 -- Make this value the amount of money that you want the player to have at the beggining
    coins.Parent = leaderstats

-- Run 'onPlayerJoin()' when the 'PlayerAdded' event fires

now to make it increase, I am not going to type out everything because I don't know what you want to call this, but anyways write this under your leaderstats code

if game.Workspace.WhateveryourmonsterNameis.Humanoid.Health == 0 then
    player.leaderstats.coins.Value = 10 + player.leaderstats.coins.Value

I probably have a lot of errors so you might want to proofread it, but other than that It's got the correct logic


Answer this question