Trouble making it so when a part is touched a value gets added to the leaderboard

hello Roblox developers I’m having a little bit of trouble trying to make it so when a part is touched, a numeral value gets added onto the leaderboard. and I have not had any success so far. Any help would be appreciated! here’s my code below

local part = script.Parent

local function touched(Player)
	local level = Player.leaderstats.level
	level.Value = level.Value + 1
end

part.Touched:Once(touched)
1 Like

The part that touched the part isn’t a player make sure to write like this :

local Part = script.Parent

local function touched(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	
	if Player then
		local level = Player.leaderstats.level
		level.Value = level.Value + 1
	end
end

Part.Touched:Once(touched)

Hope it’s helpful !

1 Like

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