You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
When I pass a folder to a function I would like it to still be a folder inside the function. I’d like to get this code working.
- What is the issue? Include screenshots / videos if possible!
I am passing a Folder to a function in a module and when I breakpoint within the module the folder seems to be a table. The table contains 1 function, that’s all.
Some relevant code:
RollingClient:
local replicatedStorage = game:GetService("ReplicatedStorage")
local remotes = replicatedStorage:WaitForChild("Remotes")
local animationModule = require(script:WaitForChild("AnimationModule"))
local screenGUI = script.Parent
local animations = screenGUI:WaitForChild("Animations")
local rollButton = screenGUI:WaitForChild("RollButton")
local debounce = false
rollButton.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
local rolledNumber = remotes.RollFunction:InvokeServer()
animationModule:rollAnimation(animations, rolledNumber) -- PASS FOLDER
task.wait(1)
debounce = false
end
end)
AnimationModule:
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local function animateText(text1, text2, rolledNumber)
text1.Position = UDim2.fromScale(0.5, 0.35)
text1.TextColor = rolledNumber[3]
text1.Text = rolledNumber[1]
text2.Text = "1 of " .. rolledNumber[2]
tweenService:Create(text1, info, {Position = UDim2.fromScale(0.5, 0.5)}):Play()
task.wait(0.2)
end
return {
rollAnimation = function(animationFolder: Folder, rolledNumber)
local background = animationFolder:WaitForChild("Background") -- HERE FOLDER LOOKS LIKE A TABLE
local title = animationFolder:WaitForChild("Title")
local rarity = title:WaitForChild("Rarity")
background.Visible = true
title.Visible = true
for i, Table in ipairs(rolledNumber) do
animateText(title, rarity, Table)
end
task.wait(1)
background.Visible = false
title.Visible = false
end,
}
Error message: Players.MeMeMe.PlayerGui.MainScreenGui.RollingClient.AnimationModule:17: attempt to call missing method ‘WaitForChild’ of table - Client - AnimationModule:17
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried using “require” to get the AnimationModule. I was thinking that would solve it, but for some reason it just thinks that folder is a table. I breakpoint just before calling the method and the folder looks fine, after I call the function I put a breakpoint inside the function, see image - looks like a table containing a function.
First question, second post - please let me know how I can improve my question. I’ve only been Roblox dev-ing with Lua for a week so be gentle - I got 99% of this watching youtube. Thanks!