Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Scripts won't load when player joins?

I was working on devil fruits. And I load the devil fruit moves based on what the player's fruit is. Heres my script:

(Error: 11:52:08.631 - ServerScriptService.MainScript.StatManager:12: bad argument #1 (table expected, got Object)

if data.DevilFruit.Value ~= "Nothing" then
		local dfmoves = game:GetService("ReplicatedStorage").DevilFruits:WaitForChild(data:WaitForChild("DevilFruit").Value.."_Fruit")
		local dfgui = game:GetService("ReplicatedStorage").DevilFruits.GUIs:WaitForChild(data:WaitForChild("DevilFruit").Value.."_GUI")

		for i, v in pairs(dfmoves) do
		v.Disabled = false
		v:Clone().Parent = player.Backpack
		end
		
		-- Give Moveset
		for i, v in pairs(dfgui) do
		wait(1)
		v.Enabled = true
		v:Clone().Parent = player.PlayerGui
		end
	end

2 answers

"dfgui" is an instance. If I had to guess, you are trying to loop through it's children.

for i,v in pairs(dfgui:GetChildren()) do --GetChildren returns an array of instances so now it is able to loop
	wait(1)
	v.Enabled = true
	v:Clone().Parent = player.PlayerGui
end

2 comments

0

14:44:25.012 - Infinite yield possible on 'ReplicatedStorage.DevilFruits:WaitForChild("_Fruit")'

0

That does not look like a problem with your for loop.

It expects you to put a table such as this

table = {}

but you put something else instead of a table, such as an object.

This discussion is preserved as it was. New answers, comments, and votes are closed.