Well, i need some help if anyone can. I've been trying for the past 30 minutes to get this working but it doesn't. I've been trying to make a script where when a player touches a part, the script takes a leader stat value from the player and multiples it by a certain value (like 1 or 4) and gives them the amount calculated.
So far I've come up with this
local player = game.Players
local Players = game.Players
local G = player:FindFirstChild("leaderstats").leaderstats:FindFirstChild("Grass").Value
local total = (G * 1)
script.Parent.Touched:Connect(function(hit)
workspace.RemoteEvent:FireServer(player.Name)
if player:FindFirstChild("leaderstats")
and player.leaderstats:FindFirstChild("Grass") then
player.leaderstats.Grass.Value = player.leaderstats.Grass.Value + total
end
end)
Although I've tried this many times i had no choice but to ask for help, in this script sofar Line 3 is showing "Attempt to Index a nil value" If anyone could help me i would be so thankful.

3 comments
You realize that player is game.Players and not a specific player, right?
Yes i do realise that after looking at the script, Im trying to direct it to a player but theres parts that still break. Im noy particularly best with coding but im assuming do i use this in a local script to define game.Players("localplayer")?
I believe my answer should help @RebornedInFire