#I need helpp
40 messages · Page 1 of 1 (latest)
local SkillZ = script.SkillZ:GetChildren()
local SkillX = script.SkillX:GetChildren()
local KeyReferences = {
[Enum.KeyCode.Z] = SkillZ,
[Enum.KeyCode.X] = SkillX
}
UIS.InputBegan:Connect(function(Input)
print(KeyReferences[Input.KeyCode])
end)
when run and I press "z" I receive this table:
but I'd like a string, not table, how I do this?
did you try doing something like this already?
local var = KeyReferences[Input.KeyCode][1]
yes, it worked, tyyyy
but I dont understanted why, u can explain me pls ?
basically it's looking for the first thing in the table, that's what the square brackets are for
so for example
local a = {"apple", "orange", "banana"}
a[1] is apple
a[2] is orange
a[3] is banana
aaah, I got it, thank you very much!!
np
@lime summit hey, can u explain me another thing pls ? how I change the "var" in a instance ? Could I do this?:
script.SkillZ:FindFirstChild(var)
can you elaborate on what you want explained? cuz I dont exactly understand what u said lol
ohhhh
** You are now Level 1! **
have you tested if it works?
i think the issue might be that var or whatever you want the variable to be named is an instance and not a string, try using require(var) if it works