I'm trying to make a script which i would put inside trophies around the map and display how many trophies each player has however after a whole afternoon of brainstorming i got nil
script.Parent.Touched:connect(function(hit)
if hit.Parent ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
local stats = player:WaitForChild("leaderstats")
local trophies = stats: WaitForChild("TrophiesFound")
local humanoid = hit.Parent:WaitForChild("Humanoid")
if humanoid ~= nil then
if humanoid.Health ~= 0 then
trophies.Value = player.leaderstats.TrophiesFound.Value + 1
end
end
end
end
end)
All i've got is this script that adds +1 on the list of the player who touched it but it adds 5 every time i move near it or walking over it. If you can give me any kind of tip or suggestion your input would be greatly appricated

1 comment
Fix your code block, please.