So i've made a script that puts 1 boolean inside the player for each trophy.What i'm trying to do is make it so that when a player clicks on the trophy it changes the value inside the player from true to false so that i can later store it with data service after he leaves. However this script doesn't output any errors and it also doesn't change the boolean from false to true instead i can click and it adds +1 to my trophies over and over.I've also inserted print to see if the script fires off completely and it does.
Thanks for your time
[script.Parent.ClickDetector.MouseClick:connect(function(hit)
local player = hit
if player ~= nil then
local stats = player:WaitForChild("leaderstats")
local trophies = stats:WaitForChild("Trophies")
local humanoid = player.Character:WaitForChild("Humanoid")
local p = player:FindFirstChild("Trophy1")
print 'y'
if p ~= nil and p == false then
p.Value = true
end
print 'a'
if (humanoid.Health > 0) then
trophies.Value = trophies.Value + 1
end
end
end)

2 comments
the script doesn't work , it stops at the if statement
It's a click if a player character clicks it, just assuming that anything that clicked on it is a character is bad tbh