Function wont run for some reason?

hello! im having an issue with my code and im unsure what the issue is. part of the code works but the other part just…doesnt?

Heres the parts that dont work

UIS.InputBegan:Connect(function(input, chat)
	if chat then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if CS.Value ~= "None" then
			local module = require(script.Spells)
			for i, spellCast in pairs(module.SpellFunctions) do
				module.SpellFunctions[string.lower(spellSaid)](CT.Value, char:FindFirstChild("Humanoid"))

Module Script:

module.SpellFunctions = {
	incendiere = function(args1, args2)
		if dbs.spell1 == false then
			dbs.spell1 = true
			if args1 == "Hands" then
				args2.WalkSpeed = 0
				args2.JumpHeight = 0
				args2.WalkSpeed = 16
				args2.JumpHeight = 7.2
			dbs.spell1 = false

The script worked before, and i recently just edited it (i used to use remote functions, but i changed it to remote events for convenience. Im unsure if that is whats causing the issue.)

Help would greatly be appreciated, thank you for your time

So I guess “working” prints and “aef” doesn’t?

1 Like

Nope! Working doesnt print for some reason. Im unsure where the issue is

It means it doesn’t iterate. Does “aeor” print?

1 Like

nope, what do you mean iterate?

for loops iterate over an amount of stuff returning the value of the index. (for)

This probably means that it cannot find anything in your SpellFunctions. Or that CS.Value is “None”

1 Like

I see. Im sure the CT value is not none. If thats the case how could i fix this issue? how can i make the script detect whats in the function?

First, you don’t want to change things until making sure the main stuff works. Try adding a print after every event and check to see if they print (after if chat, if input.UserInputType etc)

1 Like

i checked, everything prints unless its after this line:

module.SpellFunctions[string.lower(spellSaid)](CT.Value, char:FindFirstChild("Humanoid"))

Does a print right before that line print? Try printing spellSaid to see if it matches the required function name

1 Like

Where is this code located (Client or Server)? client, judging by the presence of userinputservice

Is CS.Value edited by the server or client?

scratch that.

What does CS.Value return, and how is CS.Value handled?

I realize my mistake, i was editing the wrong script (i have very similar scripts lol).

Thank you to those who have helped. I appreciate all of you!