Like I already have build my game but I need help on making where when I kill something it gives 10 coins.
COMMUNITY QUESTION
is there a script where when i kill something i get 10 coins?
1 answer
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
https://www.youtube.com/watch?v=RF-7AnnCKV4