Gem Script doesn't work!

Hey!
I have a gem script, but it isn’t working!
I get the gems, and the gem disappears, but it doesn’t get cloned back into workspace!
Why is this happening, I’m not getting any errors!
Script:

local Gem = script.Parent
local Debounce = false

local MapParent



Gem.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild('Humanoid') and Debounce == false then
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		if not Player:FindFirstChild('DogeTag') and Player.GemCount.Value < Player.MaxGems.Value then
			Debounce = true
			Player.Leaderstats.Gems.Value += 1
			Player.GemCount.Value += 1
			if script.Parent.Parent.Name == 'Map1' then
				MapParent = workspace.Map1
			elseif script.Parent.Parent.Name == 'Map2' then
				MapParent = workspace.Map2
			elseif script.Parent.Parent.Name == 'Map3' then
				MapParent = workspace.Map3
			end
			Gem.Parent = game:GetService('ReplicatedStorage')
			delay(20,function()
				Gem.Parent = MapParent
				Debounce = false
			end)
		end
	end
end)

Thanks for any help!

Once a script is in ReplicatedStorage, it will no longer excecute or run. In order to achieve this, you must put it in ServerScriptService or Lightning

1 Like