Answered by
4 years ago Edited 4 years ago
Since you've already got your activated event, you can just put the Character variable inside the Activated event using script.Parent.Parent
to get the character, the reason for this is because the Tool is going to be inside the player's Character while they are using the Tool right? So then you can use the Players:GetPlayerFromCharacter to then get the player from the player's Character.
02 | local tool = script.Parent |
04 | tool.Activated:Connect( function () |
07 | local Character = script.Parent.Parent |
08 | local Player = game.Players:GetPlayerFromCharacter(Character) |
09 | Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 1 |
To make it so it gives 500000 Technology to a specific player, you can make an if statement to check if the Player.Name or Player.UserId is equal to your name/UserId, depending on what you want, I'd probably recommend using UserId. If you want multiple players to also have access to this, then you can also use a table and insert the players' UserId's into the table then use table.find()
to check if their UserId is in the table.
First Example:
02 | local tool = script.Parent |
04 | tool.Activated:Connect( function () |
07 | local Character = script.Parent.Parent |
08 | local Player = game.Players:GetPlayerFromCharacter(Character) |
09 | if Player.UserId = = 283818237 then |
10 | Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 500000 |
12 | Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 1 |
Second Example(Table):
01 | local List = { 283818237 } |
04 | local tool = script.Parent |
06 | tool.Activated:Connect( function () |
09 | local Character = script.Parent.Parent |
10 | local Player = game.Players:GetPlayerFromCharacter(Character) |
11 | if table.find(List, Player.UserId) then |
12 | Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 500000 |
14 | Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 1 |
Sorry if this was a bit much, lol