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

01local function onPlayerJoin(player)
02    local leaderstats = Instance.new("Folder")
03    leaderstats.Name = "leaderstats"
04    leaderstats.Parent = player
05 
06 
07    local coins = Instance.new("IntValue")
08    coins.Name = "coins"
09    coins.Value = 0 -- Make this value the amount of money that you want the player to have at the beggining
10    coins.Parent = leaderstats
11end
12 
13-- Run 'onPlayerJoin()' when the 'PlayerAdded' event fires
14game.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

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

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