local contents = script.Parent.MapHandler
script.Parent.MapHandler.Changed:Connect(function(Gamemode)
local chosenGamemode = contents:GetAttribute("Gamemode")
if chosenGamemode == "Gem Collection" then
local players = game.Players:GetPlayers()
for i, v in pairs(game.Players:GetPlayers()) do
local gems = Instance.new("IntValue", v:FindFirstChild("leaderstats"))
gems.Name = "Gems"
end
local crystal = game.ReplicatedStorage.Crystal:Clone()
crystal.Parent = game.Workspace
repeat wait(1) until contents:GetAttribute("Round") == false
players = game.Players:GetPlayers()
for i, v in pairs(game.Players:GetPlayers()) do
if v.leaderstats:FindFirstChild("Gems") then
v.leaderstats.Gems:Destory()
end
end
crystal:Destroy()
end
end)
game.Players.PlayerAdded:Connect(function(player)
local chosenGamemode = contents:GetAttribute("Gamemode")
if chosenGamemode == "Gem Collection" and contents:GetAttribute("Round") == true then
local gems = Instance.new("IntValue")
local leaderstats = player:WaitForChild("leaderstats")
gems.Parent = leaderstats
gems.Name = "Gems"
end
end)
game.Workspace.ChildRemoved:Connect(function(child)
local chosenGamemode = contents:GetAttribute("Gamemode")
if chosenGamemode == "Gem Collection" and contents:GetAttribute("Round") == true then
if child:FindFirstChild("Humanoid") then
game.Players:FindFirstChild(child.Name).leaderstats.Gems.Value = 0
end
end
end)
I am trying to make a game-mode on my game, where you can collect gems. When the gamemode starts, you get gems as a intvalue. Once the gamemode ends, the gems leaderstats will be removed, but when the game ends, I get this error "Destory is not a valid member of IntValue “Players.DeadstayYT.leaderstats.Gems”