Not creating or cloning Item Template to a frame

The title is pretty bad, but basically, I have a “WeaponsUnlocked” folder in my player folder (Vulnerable to exploits, I know), Which has folders (primaries, secondaries, melees) that have booleanvalues in them that are the names of weapons in the game. And I wanna clone the Item Template from ReplicatedStorage and parent it to the item frame, which sets the names of the values and the images accordingly to each item. So the player can see it, if any of values are true. However, It isn’t cloning anything or isn’t printing any errors. This is my code.

script.Parent.LoadInv.Event:Connect(function(Type)
	print("load inv fired")
	for i, v in pairs(game.Players.LocalPlayer:WaitForChild("WeaponsUnlocked")[Type]:GetChildren()) do
		print("cloning: ".. Type)
		if v == true then
			local itemThing = game.ReplicatedStorage.ItemTemplate:Clone()
			itemThing.Parent = game.Players.LocalPlayer.PlayerGui.Loadout.Frame.Items.Pages.Page1
			itemThing.TextLabel.Text = v.Name
			itemThing.Image = game.ReplicatedStorage.WeaponStats[v].image.Value
		end
	end
end)

Firstly, when looping over the folder of BoolValues, the v that you are comparing to true isn’t actually whether or not the boolean value is checked, it’s the object itself. To get the value of a boolean value, you need to reference the Value property of it. In this case, using v.Value == true instead of v == true should fix that.

Next, if it’s not cloning anything or printing anything, it might not be this code. Check to see if this event is being fired at all. Are you firing this from server to client? If so, you would need to use RemoteEvents, not BindableEvents.

omg, Thank you so much. I feel so dumb right now.

Oh, and beforehand I did check if it was being fired. And it was it was just me using v instead of v.Value.

Thank you so much, again.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.