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

How do I make so whenever a player uses a tool they get a +1 leaderstats currency? [closed]

Asked by
6zk8 95
4 years ago

I want to make it so whenever a player uses a soda tool they get +1 point, which is a leaderstat currency. This is for a game im currently making so any help will be very appreciated.

0
Hello x300z, this is not a request site, please give us an example with one of your scripts. JustSxript 36 — 4y
0
Wait nvm one of your posts has answered it... 6zk8 95 — 4y

Closed as Not Constructive by hiimgoodpack and RayCurse

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.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
4 years ago

What I would use is GetPlayerFromCharacter(), since you're using a tool I see no reason why you shouldn't you use.

Like so:

Tool = script.Parent -- Define your tool
Players = game:GetService('Players') -- For defining the player

Tool.Activated:Connect(function() -- In this case, when you click down (activating the tool).
    local Player = Players:GetPlayerFromCharacter(Tool.Parent) -- Find the player's Character through the tool parent, henceforth defining the player.
    if Player then -- Just a safe check to make sure it's  found the player
        if Player:FindFirstChild('leaderstats') and Player.leaderstats:FindFirstChild('Points') then -- We make to make sure the player both has the leaderstats folder and the points value.
            Player.leaderstats.Points.Value = Player.leaderstats.Points.Value + 1 -- Now add the points
        end
    end
end)
0
Sorry, it is a bit messy due to how the website code block system works, but I hope you get the jist of it. pwx 1581 — 4y
0
ummm, is this meant to be in a localscript? User#23252 26 — 4y
0
in a LocalScript you can just do game.Players.LocalPlayer User#23252 26 — 4y
0
Do not put it in a localscript. You will not be able to replicate the new value to the server if it's not on a server script. GeneratedScript 740 — 4y
0
Server script. pwx 1581 — 4y
Ad