Script not getting past if statement

I need help!

  1. What do you want to achieve? I would like to work on a item saving system. I am likely going about it wrong.

  2. What is the issue? This script is not getting past my if statements.

  3. What solutions have you tried so far? I have searched, and have failed to find anything like this.

Here is my script:

game.Players.PlayerAdded:Connect(function(plr)
	local ServerStorage = game:GetService("ServerStorage")
	local ownedtools = plr:WaitForChild("SavedTools")
	print("player loaded")
	if ownedtools.powerUp.Value then
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("Backpack")
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("OwnedTools")
		print("got past if, should have loaded items")
	end
end)

Thank you!

make sure the Value in the tool thing is true or else it wont get past the if else statement

I have checked, and it is true on the server and the client.

Upon my testing; It got past the if statement but the issue seems to be something with ServerStorage:WaitForChild because it doesn’t even print a error for me that I don’t have it. I’ll do some further testing but I want to make it apparent to you before I do more testing.

Weird, for me it doesn’t print the “got past if, should have loaded items”.

game.Players.PlayerAdded:Connect(function(plr)
	--script.SavedTools.Parent = plr
	local ServerStorage = game:GetService("ServerStorage")
	local ownedtools = plr:WaitForChild("SavedTools")
	print("player loaded")
	if ownedtools.powerUp.Value then
		warn('got here')
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("Backpack")
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("OwnedTools")
		print("got past if, should have loaded items")
	end
end)

I added a print right after the if and it prints for me, seems as if the clone is the issue. Attempting a fix now

Try this;

game.Players.PlayerAdded:Connect(function(plr)
	local ServerStorage = game:GetService("ServerStorage")
	local ownedtools = plr:WaitForChild("SavedTools")
	print("player loaded")
	if ownedtools.powerUp.Value then
		warn('got here')
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("Backpack")
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = ownedtools
		print("got past if, should have loaded items")
	end
end)

still isn’t working for me, i did a test on mine, it didn’t print if it got past if statement.

That’s really weird because it’s printing that for me with my newest code.

But I also don’t have the exact folders that you have I only have testing folders and a testing tool;

i know… i dont know what i should do to fix this

Can you show me what your OwnedTools folder looks like?

sure, here it is
image
the folder is called saved tools in the player

also, im starting with one item for this

So to confirm, sorry about any questions:

We have a folder inside of the player called SavedTools. If the player owns this the value is true. If the value is true then we are cloning “SuperPower” to the Backpack and another folder in the player called “OwnedTools”.

	local ServerStorage = game:GetService("ServerStorage")
	local ownedtools = plr:WaitForChild("SavedTools")
	print("player loaded")
	if ownedtools.powerUp.Value then
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("Backpack")
		ServerStorage:WaitForChild("SuperPower"):Clone().Parent = plr:WaitForChild("OwnedTools")
		warn("got past if, should have loaded items")
	end

This should be your exact code and I effectively get to the “got past if” as shown below
image

To add; Look over my initialization and make sure it matches yours

	--// !! TESTING BEGAN, !!DELETE BELOW!!
	local savedTool = Instance.new('Folder')
	savedTool.Name = 'SavedTools'
	savedTool.Parent = plr
	local value = Instance.new('BoolValue')
	value.Name = 'powerUp'
	value.Parent = savedTool
	value.Value = true
	local tool = Instance.new('Tool')
	tool.Name = 'SuperPower'
	tool.Parent = game:GetService('ServerStorage')
	local fold = Instance.new('Folder')
	fold.Name = 'OwnedTools'
	fold.Parent = plr
	--// !! TESTING ENDED, !!DELETE ABOVE!!

Then to make even more of an annoyance. Where is your script located, and is it Server or Local

This matches mine pretty well, I would say.

Its also, located in ServerScriptService.

Mine is aswell, is this everything inside of your script?

its about everything, I would say!

I’m going to put this example in the other ones.

I’m going to edit something really quick, I want you to playtest and show me your output

Sure, just ignore the other stuff.