Unusual invalid argument #2 (string expected, got Instance) error?

So, I am trying to pass a string that will locate a certain stringvalue but I keep getting this unusual error no matter what.

So there’s a stringvalue, the name of the stringvalue is the name of the ability and the value inside is the cooldown
image

Local Script:

class_module["Ground_Smash"](player, character, root, humanoid, "[Z] - Ground Strike")

Modules:

MOVE["RapidStrikes"] = function(player, char, root, humanoid, nameability)
	local Class = player.Backpack[player.Data.Class.Value]
	local cooldown = game.ReplicatedStorage.Classes[Class].Moves[nameability].Name
end

However, I keep getting invalid argument #2 (string expected, got Instance) on the cooldown line. Any help?

1 Like

What are error and what line, i dont know wheres the error at

I wrote the error and where it is on the last sentence.

“invalid argument #2 (string expected, got Instance) on the cooldown line”

its because it expects a string not an instance, You can use tostring() or instance.Name

I don’t believe casting the instance to a string would help any; It’s being misread so one of the parameters aren’t the right type. Could you give us more information like your Class reference value?

I don’t think you can convert a object to a string? I may be wrong.

Could you send the hierarchy picture, something might wrong

Sure!


MOVE["RapidStrikes"] = function(player, char, root, humanoid, nameability)
	local Class = player.Backpack[player.Data.Class.Value]
	local cooldown = game.ReplicatedStorage.Classes[Class].Moves[nameability].Name
end

That’s your issue Class is an object,
Switch it to

local Class = player.Data.Class.Value

Also just a quick heads up, with your structure
cooldown is going to be the same as nameability

1 Like

Yeah, it worked! Thanks alot!

1 Like

Happy it worked, wish you luck with your project :slight_smile:

1 Like