It wont give me gems after i touch it
local deb = false
script.Parent.Touched:connect(function(hit)
if game.Players.LocalPlayer.Maxgems.Max.Value - game.Players.LocalPlayer.leaderstats.Gem.Value > 0 then
if hit.Parent:FindFirstChild("Humanoid") then
if deb == false then
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("leaderstats") then
Player.leaderstats.Gem.Value = Player.leaderstats.Gem.Value +1
workspace.CollectSound:Play()
script.Parent:Destroy()
if game.Players.LocalPlayer.leaderstats.Gem.Value > game.Players.LocalPlayer.Maxgems.Max.Value then
game.Players.LocalPlayer.leaderstats.Gem.Value = 10
end
end
end
end
end
end
deb = true
wait(0.1)
deb = false
end)
No output errors

3 comments
Please use indentation in your scripts.
ffs
create a variable "local LocalPlayer = game:GetService("Players"):FindFirstChild(hit.Parent.Name)" and use it to get the LocalPlayer. LocalPlayer does not work in a server-script