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)
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)