#Sumting wong with module script
19 messages · Page 1 of 1 (latest)
did you require it?
local mob = require(script.Mobs)
local castle = workspace.Castle
for w=1, 10 do
print("Wave", w, "starting")
mob.Spawn("Enemy1", 3 * w, castle)
mob.Spawn("Enemy2", 2 * w, castle)
mob.Spawn("Enemy3", w, castle)
while #workspace.Enemies:GetChildren() >= 1 do
task.wait(.5)
end
print("Wave", w, "ended.")
task.wait(1)
end
"Requested module had an error while loading"
are there other errors
holup im probably just fogetting something
OH
im debugging it rn ill update with any errors i dont understand
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local module = require(script.Statistics)
local mob = {}
local castle = workspace.Castle
local healthVal = castle.PlayerBase.Health
function mob.Move(mob, map)
local nodes = castle.Nodes
local node = nodes.start
local Speed = module.Data[mob.Name]["Speed"]
local MaxHealth = module.Data[mob.Name]["MaxHealth"]
local speed = 2
local rotSpeed = .1
for w=1, #nodes:GetChildren() do
local node = nodes:FindFirstChild(w)
if node then
-- rotate enemy
local rotateTween = TweenService:Create(mob, TweenInfo.new(rotSpeed, Enum.EasingStyle.Circular), {CFrame = CFrame.new(mob.Position, node.Position)})
rotateTween:Play()
rotateTween.Completed:Wait()
-- move enemy
local distance = (mob.Position - node.Position).Magnitude
local moveTween = TweenService:Create(mob, TweenInfo.new(distance / speed / Speed, Enum.EasingStyle.Linear), {Position = node.Position})
moveTween:Play()
moveTween.Completed:Wait()
end
end
healthVal.Value -= MaxHealth
mob:Destroy()
end
function mob.SpawnEnemy (name, map)
local enemy = ReplicatedStorage.Enemies:GetChildren()
local entity = enemy[math.random(1, #enemy)]:Clone()
entity.CFrame = castle.Nodes.start.CFrame
entity.Parent = workspace.Enemies
coroutine.wrap(mob.Move)(entity)
end
while healthVal.Value > 0 do
wait(2)
mob.SpawnEnemy("Enemy1", castle)
end
return mob
when I put this into a modulescript, it keeps on getting errors
the castle on castle.Node is supposed to be "map"
but when I make it "map", it says attempt to assign Nodes to nil
but surprisingly this whole code works just like this
help