Object not cloning into Backpack if bool value is true

I need help!

  1. What do you want to achieve? I wanna make my own item saving system in my game, and I know that I am probably going about it in the wrong way.

  2. What is the issue? It doesn’t clone the tool into my backpack, when it should be.

  3. What solutions have you tried so far? I haven’t really looked, but I have tried changing the way I clone the object.

This is my script for cloning.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local ownedtools = plr:WaitForChild("SavedTools")
		if ownedtools.powerUp.Value == true then
			game:GetService("ServerStorage"):WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
		if ownedtools.fireFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("FireFish"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("FireFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
		if ownedtools.pufferFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("ClassicSuperball"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("ClassicSuperball"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
		if ownedtools.grappleFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("Grapple"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("Grapple"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
		if ownedtools.rocketFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("Rocketfish"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("Rocketfish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
		if ownedtools.bombFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("BombFish"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("BombFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
		if ownedtools.bigFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("BigFish"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("BigFish"):Clone().Parent = plr:WaitForChild("OwnedTools")

		end
		if ownedtools.laserFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("LaserFish"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("LaserFish"):Clone().Parent = plr:WaitForChild("OwnedTools")

		end
		if ownedtools.dreamFish.Value == true then
			game:GetService("ServerStorage"):WaitForChild("DreamFish"):Clone().Parent = plr:WaitForChild("Backpack")
			game:GetService("ServerStorage"):WaitForChild("DreamFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
	end)
end)

Thank you!

This is a very inefficient way of doing this you can shorten it a lot by changing

if Value == true
if Value == false

to

if Value then
if not Value then

Here I made the changes


game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
        local ServerStorage = game:GetService("ServerStorage")
	    local ownedtools = plr:WaitForChild("SavedTools")

	    if ownedtools.powerUp.Value then
			ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.fireFish.Value then
			ServerStorage:WaitForChild("FireFish"):Clone().Parent = plr:WaitForChild("Backpack")
	        ServerStorage:WaitForChild("FireFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.pufferFish.Value then
			ServerStorage:WaitForChild("ClassicSuperball"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("ClassicSuperball"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.grappleFish.Value then
			ServerStorage:WaitForChild("Grapple"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("Grapple"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.rocketFish.Value then
			ServerStorage:WaitForChild("Rocketfish"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("Rocketfish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.bombFish.Value then
			ServerStorage:WaitForChild("BombFish"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("BombFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.bigFish.Value then
			ServerStorage:WaitForChild("BigFish"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("BigFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.laserFish.Value then
			ServerStorage:WaitForChild("LaserFish"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("LaserFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end

		if ownedtools.dreamFish.Value then
			ServerStorage:WaitForChild("DreamFish"):Clone().Parent = plr:WaitForChild("Backpack")
			ServerStorage:WaitForChild("DreamFish"):Clone().Parent = plr:WaitForChild("OwnedTools")
		end
	end)
end)

I mean, it cleaned it up a bit, but it didn’t fix the issue.

Try using print in each if statement

I have figured out that it will not get past the if statement. Is there a typo? I don’t know.

You reference (.Value) but what is the actual value?

A BoolValue! Thank you if you can help me :smiley:

Then you need to add (.Value == true) or (.Value == false) to your if statements.

In the original code, it has the (.Value == true)… I know, its odd.