Value prints as nil

I’m trying to print a value in a modulescript which keeps printing as nil, here’s the script, this is local btw:

local tools = {
	["Sword"] = {
		["Damage"] = 10,
		["Spot"] = "Waist",
		["Idle"] = "14116165012",
		["Walk"] = 0,
		["AttackingSpeed"] = 0
	}
}

function tools.equip(tool)
	print(tool.Idle)
	local player = game.Players.LocalPlayer
	game.ReplicatedStorage.ToolEquip:FireServer(tool, tool.Idle)
end

function tools.unequip(tool)
	local player = game.Players.LocalPlayer
	game.ReplicatedStorage.ToolUnequip:FireServer(tool)
end

return tools
1 Like

From my understanding your module will have different tools, and Sword is one of them. So when you pass a tool into equip and unequip functions, you are taking the data from the table by their name.

function tools.equip(tool) -- say we pass a tool named 'Sword'
	if tools[tool.Name] then -- check if data for the tool exists
		print(tools[tool.Name].Damage)
	end
end

Aside from the above, Idle is probably the animation ID, which should be played locally. You don’t have to send it to the server, because the proper way is to play and stop on the client’s side.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.