I need help with my tower script

  1. What do you want to achieve? Keep it simple and clear!
    I want to make it so whenever I use this function it will add height the the tower. It keeps coming back with an error that says
ServerScriptService.Script:4: attempt to call missing method 'addHeight' of table
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I could not find any solutions
    Here is my module for it
local Tower = {}
Tower.__Index = Tower

function Tower.new()
	local newTower = {}
	setmetatable(newTower, Tower)
	
	newTower.Height = 0
	
	return newTower
end

function Tower:addHeight()
	self.Height = self.Height + 5
end

return Tower

Here is the script

local TowerModule = require(game.ReplicatedStorage.Tower)

local newTower = TowerModule.new()
newTower:addHeight()
1 Like
function Tower.new()
	local newTower = {}

	newTower.Height = 0
	
	return setmetatable(newTower, Tower)
end

It still comes out with the same error.

It’s __index (lowercase i)

1 Like

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