Items keep disappearing after being "upgraded"

  1. What do you want to achieve? Keep it simple and clear!

I want the items to be upgraded into other ones

  1. What is the issue? Include screenshots / videos if possible!

Some of them keep disappearing

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to put it in a table and using the wait() function

local whatsetting = script.Parent.Parent:WaitForChild("whatsetting")
local cftomodify = script.Parent.Parent.setting2.Motor6D
local cftomodify2 = script.Parent.Parent.keypart.Motor6D
local thekey = script.Parent.Parent.thekey

local doorcftomodify = script.Parent.Parent.doors.what.move
local doorcftomodify2 = script.Parent.Parent.doors.what2.move



function makecframeorien(x,y,z)
	
	return CFrame.fromOrientation(math.rad(x),math.rad(y),math.rad(z))
end

local roughcf = CFrame.new(-0.058, -0.004, -0.15)*makecframeorien(-90, 90, 0 )

local coarsecf = CFrame.new(-0.028, 0.036, -0.15)*makecframeorien(-45, 90, 0)

local onetoonecf = CFrame.new(-0, 0.05, -0.15)*makecframeorien(0, 90, 0)

local finecf = CFrame.new(0.028, 0.036, -0.15)*makecframeorien(45, 90, 0)

local veryfinecf = CFrame.new(0.058, -0.004, -0.15)*makecframeorien(90, 90, 0)

local normalkeycf = CFrame.new(0.357, 0.01, -0.001)*makecframeorien(90, 180, 0)

local keyturncf = CFrame.new(0.357, 0.01, -0.001)*makecframeorien(-0, 0, 180)

local dooropencf = CFrame.new(0, -3.3, 0)*makecframeorien(0, 0, 0)

local doorclosedcf = CFrame.new(0, 3.3, 0)*makecframeorien(0, 0, 0)

local debounce = false
local beingused = false

function tween(what,info,desti)
	game:GetService("TweenService"):Create(what, info, desti):Play()
end

script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(function(plr)
	if debounce == false and beingused == false then
		
	if whatsetting.Value == "rough" then
			script.Parent.toggle:Play()
		whatsetting.Value = "coarse"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = coarsecf})
	elseif whatsetting.Value == "coarse" then
			script.Parent.toggle:Play()
		whatsetting.Value = "1:1"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = onetoonecf})
	elseif whatsetting.Value == "1:1" then
			script.Parent.toggle:Play()
		whatsetting.Value = "fine"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 =finecf})
	elseif whatsetting.Value == "fine" then
			script.Parent.toggle:Play()
		whatsetting.Value = "veryfine"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = veryfinecf})
	end
	debounce = true
	wait(0.5)
	debounce = false
	end
end)

script.Parent:WaitForChild("ClickDetector").RightMouseClick:Connect(function(plr)
	if debounce == false and beingused == false then
		
	if whatsetting.Value == "coarse" then
			script.Parent.toggle2:Play()
		whatsetting.Value = "rough"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = roughcf})
	elseif whatsetting.Value == "1:1" then
			script.Parent.toggle2:Play()
		whatsetting.Value = "coarse"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = coarsecf})
	elseif whatsetting.Value == "fine" then
			script.Parent.toggle2:Play()
		whatsetting.Value = "1:1"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = onetoonecf})
	elseif whatsetting.Value == "veryfine" then
			script.Parent.toggle2:Play()
		whatsetting.Value = "fine"
		tween(cftomodify, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = finecf})
	end
	debounce = true
	wait(0.5)
	debounce = false
	end
end)

function checkcollide(thing)
	local success = pcall(function()
		local x = thing.CanCollide
	end)

	return success
end



local itemin914list = {}

thekey.ClickDetector.MouseClick:Connect(function(plr)
	if debounce == false and beingused == false then
		beingused = true
		spawn(function()
			tween(cftomodify2, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = keyturncf})
			wait(1)
			tween(cftomodify2, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {C0 = normalkeycf})
		end)
		
		tween(doorcftomodify, TweenInfo.new(2.15, Enum.EasingStyle.Quad), {C0 = doorclosedcf})
		
		spawn(function()
			wait(1)
			tween(doorcftomodify2, TweenInfo.new(2.15, Enum.EasingStyle.Quad), {C0 = doorclosedcf})
			doorcftomodify2.Parent.Parent.door2.close:Play()
			
wait(2)
			for i,v in ipairs(workspace:GetPartsInPart(script.Parent.Parent.itemhitbox)) do

				if v.Name == "HumanoidRootPart" then
					local humm = v.Parent.Humanoid

					if humm then
						if game:GetService("Players"):GetPlayerFromCharacter(humm.Parent) then
							humm.Parent["914"]:FireClient(game:GetService("Players"):GetPlayerFromCharacter(humm.Parent), true)

							wait(7)

							humm.Parent["914"]:FireClient(game:GetService("Players"):GetPlayerFromCharacter(humm.Parent), false)
						end
					end
				end
				wait()
			end
		end)
		
		doorcftomodify.Parent.Parent.door.close:Play()
		
		
		script.Parent.Parent.base.refine:Play()
		
		
		
		wait(8)
		spawn(function()
		
for i,v in ipairs(workspace:GetPartsInPart(script.Parent.Parent.itemhitbox)) do
			
	if v.Name == "HumanoidRootPart" then
				local humm = v.Parent.Humanoid
				
		if humm then
			
					local tool = humm.Parent:FindFirstChildWhichIsA("Tool")
					
			if not tool then
				if whatsetting.Value == "rough" then
					humm.Health = humm.Health / 4

				elseif whatsetting.Value == "coarse" then
					humm.Health = humm.Health / 2


				elseif whatsetting.Value == "1:1" then
					local walkspeed = humm.WalkSpeed
					local jumppower = humm.JumpPower
					local maxhealth = humm.MaxHealth
					local health = humm.Health
					
					humm.JumpPower = walkspeed
					humm.WalkSpeed = jumppower
					
					humm.MaxHealth = health
					humm.Health = maxhealth
					
					game.ServerScriptService.effects["fast death"]:Clone().Parent = humm.Parent



				elseif whatsetting.Value == "fine" then
						local walkspeed = humm.WalkSpeed
						local jumppower = humm.JumpPower
						local maxhealth = humm.MaxHealth
						local health = humm.Health
						
						if humm.MaxHealth < 150 then
						
						humm.MaxHealth = maxhealth + 10
						humm.Health = humm.MaxHealth
						
						end
						
						if humm.WalkSpeed < 18 then

							humm.WalkSpeed = walkspeed + 2

						end
						
						if humm.JumpPower < 40 then

							humm.JumpPower = jumppower + 2

						end
						
						

					

				elseif whatsetting.Value == "veryfine" then
						game.ReplicatedStorage.teamswitch:Fire(plr, "creature", "", "SCPs", false, plr, script.Parent.Parent.itemspawn.Position)
					
				end
				
				
			else
				
						

						if tool and tool:FindFirstChild("Rough") and tool:FindFirstChild("Coarse") and tool:FindFirstChild("1:1") and tool:FindFirstChild("Fine") and tool:FindFirstChild("Very Fine") then
							print(tool.Name)
							if tool.Rough.Value == nil and whatsetting.Value == "rough" then
								tool:Destroy()

							elseif tool and tool.Rough.Value and whatsetting.Value == "rough" then
								local upgradeditem = tool.Rough.Value:Clone()
								upgradeditem.Parent = humm.Parent

								repeat wait() until upgradeditem

								tool:Destroy()


							elseif tool and tool.Coarse.Value == nil and whatsetting.Value == "coarse" then
								tool:Destroy()

							elseif tool and tool.Coarse.Value and whatsetting.Value == "coarse" then
								local upgradeditem = tool.Coarse.Value:Clone()
								upgradeditem.Parent = humm.Parent
						

								repeat wait() until upgradeditem
								tool:Destroy()


							elseif tool and tool["1:1"].Value == nil and whatsetting.Value == "1:1" then
								tool:Destroy()

							elseif tool and tool["1:1"].Value and whatsetting.Value == "1:1" then
								local upgradeditem = tool["1:1"].Value:Clone()
								upgradeditem.Parent = humm.Parent
								repeat wait() until upgradeditem
								tool:Destroy()


							elseif tool and tool.Fine.Value == nil and whatsetting.Value == "fine" then
								tool:Destroy()

							elseif tool and tool.Fine.Value and whatsetting.Value == "fine" then
								local upgradeditem = tool["Fine"].Value:Clone()
								upgradeditem.Parent = humm.Parent

								repeat wait() until upgradeditem
								tool:Destroy()


							elseif tool and tool["Very Fine"].Value == nil and whatsetting.Value == "veryfine" then
								tool:Destroy()

							elseif tool and tool["Very Fine"].Value and whatsetting.Value == "veryfine" then
								local upgradeditem = tool["Very Fine"].Value:Clone()
								upgradeditem.Parent = humm.Parent
		
								repeat wait() until upgradeditem
								tool:Destroy()
							end
						end
					
				
			end
			
				v.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Parent.itemspawn.Position))
	end
end
			
			if v:FindFirstAncestorWhichIsA("Tool") then
				
				local tool = v:FindFirstAncestorWhichIsA("Tool")
				
				if tool and tool:FindFirstChild("Rough") and tool:FindFirstChild("Coarse") and tool:FindFirstChild("1:1") and tool:FindFirstChild("Fine") and tool:FindFirstChild("Very Fine") then
					
					
					table.insert(itemin914list, tool)
					
					
					
				end
			end
			
end
wait()
			for i,tool in pairs(itemin914list) do
				print(tool.Name)
				if tool and tool:FindFirstChild("Rough") and tool:FindFirstChild("Coarse") and tool:FindFirstChild("1:1") and tool:FindFirstChild("Fine") and tool:FindFirstChild("Very Fine") then
				if tool.Rough.Value == nil and whatsetting.Value == "rough" then
					tool:Destroy()

				elseif tool and tool.Rough.Value and whatsetting.Value == "rough" then
					local upgradeditem = tool.Rough.Value:Clone()
					upgradeditem.Parent = workspace
					upgradeditem:PivotTo(CFrame.new(script.Parent.Parent.itemspawn.Position))

					for i,v in pairs(tool:GetDescendants()) do
						if checkcollide(v) == true then
							v.CanCollide = true
							v.CollisionGroup = "dropped"

						end
					end

					repeat wait() until upgradeditem

					tool:Destroy()


				elseif tool and tool.Coarse.Value == nil and whatsetting.Value == "coarse" then
					tool:Destroy()

				elseif tool and tool.Coarse.Value and whatsetting.Value == "coarse" then
					local upgradeditem = tool.Coarse.Value:Clone()
					upgradeditem.Parent = workspace
					upgradeditem:PivotTo(CFrame.new(script.Parent.Parent.itemspawn.Position))
					for i,v in pairs(tool:GetDescendants()) do
						if checkcollide(v) == true then
							v.CanCollide = true
							v.CollisionGroup = "dropped"

						end
					end
					repeat wait() until upgradeditem
					tool:Destroy()


				elseif tool and tool["1:1"].Value == nil and whatsetting.Value == "1:1" then
					tool:Destroy()

				elseif tool and tool["1:1"].Value and whatsetting.Value == "1:1" then
					local upgradeditem = tool["1:1"].Value:Clone()
					upgradeditem.Parent = workspace
					upgradeditem:PivotTo(CFrame.new(script.Parent.Parent.itemspawn.Position))
					for i,v in pairs(tool:GetDescendants()) do
						if checkcollide(v) == true then
							v.CanCollide = true
							v.CollisionGroup = "dropped"

						end
					end
					repeat wait() until upgradeditem
					tool:Destroy()


				elseif tool and tool.Fine.Value == nil and whatsetting.Value == "fine" then
					tool:Destroy()

				elseif tool and tool.Fine.Value and whatsetting.Value == "fine" then
					local upgradeditem = tool["Fine"].Value:Clone()
					upgradeditem.Parent = workspace
					upgradeditem:PivotTo(CFrame.new(script.Parent.Parent.itemspawn.Position))
					for i,v in pairs(tool:GetDescendants()) do
						if checkcollide(v) == true then
							v.CanCollide = true
							v.CollisionGroup = "dropped"

						end
					end
					repeat wait() until upgradeditem
					tool:Destroy()


				elseif tool and tool["Very Fine"].Value == nil and whatsetting.Value == "veryfine" then
					tool:Destroy()

				elseif tool and tool["Very Fine"].Value and whatsetting.Value == "veryfine" then
					local upgradeditem = tool["Very Fine"].Value:Clone()
					upgradeditem.Parent = workspace
					upgradeditem:PivotTo(CFrame.new(script.Parent.Parent.itemspawn.Position))
					for i,v in pairs(tool:GetDescendants()) do
						if checkcollide(v) == true then
							v.CanCollide = true
							v.CollisionGroup = "dropped"

						end
					end
					repeat wait() until upgradeditem
					tool:Destroy()
				end
			--	table.remove(itemin914list, tool)
				end
				
				wait()
				end
		end)
		

		
		wait(4)
		
		tween(doorcftomodify, TweenInfo.new(2.15, Enum.EasingStyle.Quad), {C0 = dooropencf})
		tween(doorcftomodify2, TweenInfo.new(2.15, Enum.EasingStyle.Quad), {C0 = dooropencf})

		doorcftomodify.Parent.Parent.door.open:Play()
		doorcftomodify2.Parent.Parent.door2.open:Play()
		
		beingused = false
	end
end)

Might take a long time for me to respond due to me going away from my computer

If you want people to be able to help fix your code you really need to organize the code. I see variables that have no clear name at all. I know you’re probably a beginner but please look into module scripts. Nobody wants to look through all that code.

2 Likes

Maybe some of the cards aren’t specified therefore aren’t “upgraded”. Also what is .Coarse.Value because it might be deleting some of the cards

1 Like

Alright, I will look into it

charss