{FIX} "Points" score is not reset

  1. What do you want to achieve? When my character touches “Part100” my points are reset to zero

  2. What is the issue?
    It reacts to touches, but it does not reset points

ERROR

local Part100 = script.Parent

Part100.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		
		local PlayerPoind = hit.leaderstats.Points
		PlayerPoind.Value = PlayerPoind.Value - PlayerPoind.Value

	end
end)
  1. What solutions have you tried so far?
    Searched did not find.

Is this a local script or a server script, you could also do for taking away points:
PlayerPoind.Value = 0

Script in “Part100”, possibly on the server (may be wrong)

If your leaderstats are stored in the player, you didn’t specify the player but the character, to do so:

local Part100 = script.Parent

Part100.Touched:Connect(function(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if hit.Parent:FindFirstChild("Humanoid") then
		
		local PlayerPoind = player.leaderstats.Points
		PlayerPoind.Value = 0

	end


end)
1 Like

Everything works And if it’s not a secret what was my mistake?

in the script you said that the leaderstats are in the character’s bodypart:

(hit is the bodypart that hit the part)
local PlayerPoind = hit.leaderstats.Points

You have to get the player from the character which can be done like so:
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

I will know for the future thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.