Script not working correctly

I’m trying to make it so if a name is found within a table it’d clone something and name it something that’s under another tabel but it’s not working and I’m confused why because I have other scripts utilizing the same method/table and it work’s fine but for some reason it’s not working for me. The script is below;

for v9, v10 in pairs(v1) do
	if table.find(v10.CharacterLockedName, l__Value__7) or v10.PersonLocked == false then
		local v11 = script.Parent.Spells.Button:Clone();
		v11.Visible = true;
		v11.Name = v10.Key;
		v11.Text = v10.Key;
		v11.Parent = script.Parent.Spells;
		v11.MouseButton1Click:Connect(function()
			script.Parent.Magic.Cost.Text = "Magic Cost: " .. v10.Magic;
			script.Parent.Magic.Cooldown.Text = "Cooldown: " .. v10.Cooldown;
			script.Parent.Whatdoesitdo.Itdoes.Text = tostring(v9);
		end);
	end;
end;

^
(I’m referring to this part of the script)

local v1 = require(game.ReplicatedStorage.ReplicatedModules.SpellsConfiguration);
local l__LocalPlayer__2 = game.Players.LocalPlayer;
local l__SoundService__3 = game:GetService("SoundService");
local l__UserInputService__4 = game:GetService("UserInputService");
if l__LocalPlayer__2:FindFirstChild("CharacterConfiguration") == nil then
	while true do
		wait();
		if l__LocalPlayer__2:FindFirstChild("CharacterConfiguration") then
			break;
		end;	
	end;
end;
if not l__LocalPlayer__2.Character then
	local v5 = l__LocalPlayer__2.CharacterAdded:Wait();
end;
local v6 = l__LocalPlayer__2.CharacterConfiguration or l__LocalPlayer__2:WaitForChild("CharacterConfiguration");
local l__Value__7 = v6:WaitForChild("CharacterName", 2).Value;
local l__Value__8 = v6:WaitForChild("OutfitName", 2).Value;
if v6.Specie.Value == "Witches" or v6.Specie.Value == "Werewitches" or v6.Specie.Value == "Siphoners" or v6.Specie.Value == "Heretics" or v6.Specie.Value == "Tribrids" then
	script.Parent.Parent.MainGuiFrame.buttons.GrimButton.Visible = true;
else
	script.Parent.Parent.MainGuiFrame.buttons.GrimButton.Visible = false;
end;
l__UserInputService__4.LastInputTypeChanged:Connect(function()
	if not v6 or not v6:FindFirstChild("Specie") then
		return;
	end;
	if v6.Specie.Value ~= "Witches" and v6.Specie.Value ~= "Werewitches" and v6.Specie.Value ~= "Siphoners" and v6.Specie.Value ~= "Heretics" and v6.Specie.Value ~= "Tribrids" then
		script.Parent.Parent.MainGuiFrame.buttons.GrimButton.Visible = false;
		return;
	end;
	script.Parent.Parent.MainGuiFrame.buttons.GrimButton.Visible = true;
end);
local u1 = false;
local l__Parent__2 = script.Parent;
l__UserInputService__4.InputBegan:Connect(function(p1, p2)
	if p2 then
		return;
	end;
	if p1.KeyCode == Enum.KeyCode.M and v6 and v6:FindFirstChild("Specie") and (v6.Specie.Value == "Witches" or v6.Specie.Value == "Werewitches" or v6.Specie.Value == "Siphoners" or v6.Specie.Value == "Heretics" or v6.Specie.Value == "Tribrids") then
		if u1 == false then
			u1 = true;
			l__SoundService__3:PlayLocalSound(l__Parent__2.Parent.Audio.OpenGrimoire);
			script.Parent.Visible = true;
			return;
		end;
		if u1 == true then
			l__SoundService__3:PlayLocalSound(l__Parent__2.Parent.Audio.CloseGrimoire);
			u1 = false;
			script.Parent.Visible = false;
			return;
		end;
		if script.Parent.Parent.TutorialGuide.Visible == true or script.Parent.Parent.Settings.Visible == true or script.Parent.Parent.Phone.Visible == true then
			l__SoundService__3:PlayLocalSound(l__Parent__2.Parent.Audio.CloseGrimoire);
			u1 = false;
			script.Parent.Visible = false;
		end;
	end;
end);
script.Parent.Parent.MainGuiFrame.buttons.GrimButton.MouseButton1Click:Connect(function()
	if v6 and v6.Specie and (v6.Specie.Value == "Witches" or v6.Specie.Value == "Werewitches" or v6.Specie.Value == "Siphoners" or v6.Specie.Value == "Heretics" or v6.Specie.Value == "Tribrids") then
		if u1 == false then
			u1 = true;
			l__SoundService__3:PlayLocalSound(l__Parent__2.Parent.Audio.OpenGrimoire);
			l__Parent__2.Visible = true;
			return;
		end;
		if u1 == true then
			l__SoundService__3:PlayLocalSound(l__Parent__2.Parent.Audio.CloseGrimoire);
			u1 = false;
			l__Parent__2.Visible = false;
			return;
		end;
		if script.Parent.Parent.TutorialGuide.Visible == true or script.Parent.Parent.Settings.Visible == true or script.Parent.Parent.Phone.Visible == true then
			l__SoundService__3:PlayLocalSound(l__Parent__2.Parent.Audio.CloseGrimoire);
			u1 = false;
			script.Parent.Visible = false;
		end;
	end;
end);
script.Parent.Charname.Text = "Incantations for: " .. l__Value__7;
for v9, v10 in pairs(v1) do
	if table.find(v10.CharacterLockedName, l__Value__7) or v10.PersonLocked == false then
		local v11 = script.Parent.Spells.Button:Clone();
		v11.Visible = true;
		v11.Name = v10.Key;
		v11.Text = v10.Key;
		v11.Parent = script.Parent.Spells;
		v11.MouseButton1Click:Connect(function()
			script.Parent.Magic.Cost.Text = "Magic Cost: " .. v10.Magic;
			script.Parent.Magic.Cooldown.Text = "Cooldown: " .. v10.Cooldown;
			script.Parent.Whatdoesitdo.Itdoes.Text = tostring(v9);
		end);
	end;
end;
local l__Search__3 = script.Parent.Search;
local l__Spells__4 = script.Parent.Spells;
function UpdateInputOfSearchText()
	local v12 = string.upper(l__Search__3.Text);
	local v13, v14, v15 = pairs(l__Spells__4:GetChildren());
	while true do
		local v16, v17 = v13(v14, v15);
		if v16 then

		else
			break;
		end;
		v15 = v16;
		if v17:IsA("TextButton") then
			if v17.Name ~= "Button" then
				if v12 ~= "" then
					if string.find(string.upper(v17.Name), v12) ~= nil then
						v17.Visible = true;
					else
						v17.Visible = false;
					end;
				else
					v17.Visible = true;
				end;
			end;
		end;	
	end;
end;
l__Search__3.Changed:Connect(UpdateInputOfSearchText);
1 Like

Okay before I actually respond. Wow, that’s a lot of repetitive variables.

2 Likes

Well thanks I guess, I’ll be waiting for your response.

1 Like

Sorry for the long wait, I’ve been tryna figure it out. Could you explain the highlighted code? I think I’m trippin because of the variables and it’s kinda hard to remember which variable represents which thing

Well if you read the code beneath the highlighted I’m sure you’d understand but I’m trying to get the table from another script which I required (v1) and I’m trying to make it so if it finds the character’s name in that table then a button would clone inside of a GUI with the name of that spell and the cost and cooldown, it does work but it doesn’t fully clone all of the spells needed, I also tried the code in another experience of mine and it worked perfectly but it’s not working in the other experience of mine which is the same thing.

1 Like

Try printing v1 and seeing if all the contents are int here I guess? And if it is, maybe try printing v11 and v12 and really just doing a whole bunch of stuff to see if it really is checking all the spells

If it’s working in another game, then you probably don’t need me. Just keep printing and see what’s going on.