I’m trying find the player so I can change the leaderstats but when I do that it returns Player as nil using Tool.Activated:Connect(function(Player)
I don’t know what I can do to find the Player that activated the tool
local Tool = script.Parent
local ToolModule = require(game.ReplicatedStorage:WaitForChild("Tools"))
local Animation = Instance.new("Animation")
Animation.AnimationId = ("rbxassetid://"..ToolModule[Tool.Name].AnimationID)
local track
local cooldown = false
Tool.Activated:Connect(function(Player)
if cooldown == false then
cooldown = true
track = script.Parent.Parent:WaitForChild("Humanoid"):LoadAnimation(Animation)
track.Priority = Enum.AnimationPriority.Action
track:Play()
wait(0.3)
Tool.Brush.ParticleEmitter.Enabled = true
wait(0.1)
Tool.Brush.ParticleEmitter.Enabled = false
wait(2)
local Gain = ToolModule[Tool.Name]
Player.playerstats.Backpack.Value = Player.playerstats.Backpack.Value + Gain
cooldown = false
else
print("Cooldown!")
end
end)