I'm trying to make this code so when the Pickaxe touches the Wall it give one gem (or point to the value) and then it ends. But when I test it it crashes studio entirely....
Code:
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gemstats = Instance.new("IntValue")
gemstats.Name = "Gems"
gemstats.Value = 1
gemstats.Parent = leaderstats
while true do
local Wall = game.Workspace.Part
local diamondarmor = game.StarterPack:FindFirstChild("Pickaxe")
Wall.Touched:Connect(function(otherPart)
if diamondarmor then
gemstats.Value = gemstats.Value + 1
end
end)
end
end)```
** You are now Level 1! **