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

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

Asked by 4 years 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
0
Answered by 4 years ago

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

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


    local coins = Instance.new("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
end

-- Run 'onPlayerJoin()' when the 'PlayerAdded' event fires
game.Players.PlayerAdded:Connect(onPlayerJoin)

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
end

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

Ad

Answer this question