Hello. I’ve been having a problem understanding how these work, and need some help with them. It might sound very obvious to some, but I’m struggling with tables inside tables. I’ve looked around on the DevForum and have been searching online for hours, but I can’t find out what my problem is.
Basically, everytime I try to put a table inside of another table, the script keeps getting the incorrect values, or just returning nil.
I made a basic test:
animationstable = {
["test"] = "a"
}
This hasn’t worked. I’ve also tried removing and adding various brackets, such as:
animationstable = {
["test"] = {
["a"]}
}
And:
animationstable = {
["test"] = {
"a"}
}
Again, this may be very obvious to many, and you might be facepalming, but this is basically the first time I’ve started using tables. Any help would be appreciated, and if you find any posts that might answer my question, I’d like to have their links, please.
If this is relevant, this is the whole script (Local Script):
animationstable = {
["test"] = "AnimationTest", "rbxassetid://6886877145", "rbxassetid://6886883188"
}
local debounce = false
local plr = game.Players.LocalPlayer
script.Parent.Activated:connect(function()
if debounce == false then
debounce = true
if script.Parent.Parent.AnimationMenu.Text ~= "No Current Animation" then
if script.Parent.Parent.TargetAnimation.Text ~= "No target inputted" then
for index, player in pairs(game.Players:GetPlayers()) do
if player.Name == script.Parent.Parent.TargetAnimation.Text then
local target = player.Name
for index2, child in pairs(animationstable) do
if child[1] == script.Parent.Parent.AnimationMenu.Text then
animationid = child[2]
animationidleid = child[3]
print(animationid)
print(animationidleid)
break
end
end
plr:WaitForChild("Backpack").AnimationScript.AnimateScript:FireServer(target, animationid, animationidleid)
script.Parent.Text = "Inserting animation..."
wait(1.5)
script.Parent.Text = "Send animation to victim"
debounce = false
else
script.Parent.Text = "This player doesn't exist ingame!"
wait(1.5)
script.Parent.Text = "Send animation to victim"
debounce = false
end
end
else
script.Parent.Text = "You haven't inputted a player!"
wait(1.5)
script.Parent.Text = "Send animation to victim"
debounce = false
end
else
script.Parent.Text = "You haven't chosen an animation!"
wait(1.5)
script.Parent.Text = "Send animation to victim"
debounce = false
end
end
end)
The script is toggled when the GUI button is activated, and an animation from a menu is chosen, along with a player’s name being typed into one of the boxes… It sends a remoteevent to the player’s backpack (where the server script is stored for now), which then loads the animations onto the selected player, server side. I don’t think the server script is important, as the problem is ONLY occuring in this script.
Thank you for any help!