Ad
Log in to vote
0

How do you make a Object add money onto a Leaderboard? [closed]

Asked by 12 days ago

Basically, what I am trying to do is the following:

Make a Chest which on touch removes. Then It adds on Money (Lets say 10) Onto the Leaderstats.

I need the Leaderstats part. If anyone could help this would help me complete my first step for my game!

0
Btw my actual account is DarknessFriggus, I forgot what my old account for this was. DARKSTAR1236353456 -5 — 12d
0
It appears your previous account name was bozley56. Try resetting your password for that account. If you can not get a password reset link due to an invalid email or other reason, contact support at https://scriptinghelpers.org/contact M39a9am3R 2759 — 12d
0
@M39 Yeah it was from ages and ages ago. DARKSTAR1236353456 -5 — 12d
0
script.Parent.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then game.leaderstats.money.Value = game.leaderstats.money.Value + 10 end end ) supershadnew 5 — 9d

Closed as Not Constructive by ChipioIndustries, JamesLWalker, jjwood1600, and RubenKan

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

1 answer

Log in to vote
0
Answered by
Thetacah 284
12 days ago
Edited 12 days ago

This site is not for requests, but since I'm feeling nice I can give you a quick sample. Of course, this is just a basic script that you might want to add more checks or things to improve efficiency.

You would accomplish this by using the .Touchedevent. You can read more about that here:

I do know that this script can be flawed, but it should work.

local part=script.Parent --The script is in the part that would give you money


part.Touched:connect(function(hit) --Creating our anonymous function. -Fires when anything hits the part

end)

Now that we are inside the .Touched function:

if(game.Players:GetPlayerFromCharacter(hit.Parent) and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid").Health>0) then --Making sure what hit the part was indeed a player...an alive player.

local player=game.Players:GetPlayerFromCharacter(hit.Parent)
local leaderstats=player:WaitForChild("leaderstats", 5) --Waiting for leaderstats in the player

if(leaderstats) then
local money=leaderstats:FindFirstChild("Money")
if(money) then
money.Value=money.Value+50 --Increasing the player's money value by 50
end

end 

end
part:Destroy() --Destroy the part at the end

Full script:

local part=script.Parent --The script is in the part that would give you money


part.Touched:connect(function(hit) --Creating our anonymous function. -Fires when anything hits the part
if(game.Players:GetPlayerFromCharacter(hit.Parent) and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid").Health>0) then --Making sure what hit the part was indeed a player...an alive player.

local player=game.Players:GetPlayerFromCharacter(hit.Parent)
local leaderstats=player:WaitForChild("leaderstats", 5) --Waiting for leaderstats in the player

if(leaderstats) then
local money=leaderstats:FindFirstChild("Money")
if(money) then
money.Value=money.Value+50 --Increasing the player's money value by 50
end

end 

end
part:Destroy() --Destroy the part at the end

end)

0
**identation** RubenKan 1036 — 10d
Ad
Ad