Hit for point not working

Hello!

Here is my script that has the error:

script.Parent.Touched:Connect(function(hit)
local bobs = script.Parent
local player = game.Players.LocalPlayer

if bobs.Touched.Parent == player then
	player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
end
end)

(Its a Script inside a part)

Thanks!

Welp

You cannot get the LocalPlayer in a Server Script if that’s what you’re attempting to do, you have to instead reference the Player calling GetPlayerFromCharacter()

Also, what exactly are you trying to do here? You’re attempting to equal if the “Player object” is equal to an Event is supposed to be

This should work?

local bobs = script.Parent
local DB = false

bobs.Touched:Connect(function(Hit)
    local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)

    if Player and not DB then
        DB = true
        player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
        wait(1)
        DB = false
    end
end)

Also I’d recommend implementing a DB to prevent fast spam from occuring

You can’t access game.Players.LocalPlayer is a server script…

You should also consider a debounce, to avoid your script from breaking.

Debounce - Roblox

you cannot get the local player from a server script.