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.
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)
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?