#I need help on this as I am following a tutorial and the error doesn't seem to be adding up.

38 messages · Page 1 of 1 (latest)

lime sequoia
#

I can send code if needed

#

Errors say that I'm not using coroutine right.

carmine drift
#

can i see the code

lime sequoia
#

Sure no problem

#

Studio is updating right now.

#

It just opened

#

It couldnt send

#

I think it reached the capacity

carmine drift
#

well send a .txt

lime sequoia
#

It is 64 lines lol

#

Didn't let me do that either.

carmine drift
#

well then i think its gonna be hard

lime sequoia
#

Oh

#

Maybe I send it piece by piece?

#

Or I send a doc link maybe

frosty deltaBOT
#

studio** You are now Level 1! **studio

lime sequoia
#

Error is this: ServerScriptService.Main.Tower:57: ServerScriptService.Main.Tower:15: attempt to perform arithmetic (sub) on Vector3 and Instance

#

Main.Tower:57 is coroutine.wrap(tower.Attack)(newTower)

#

Any Ideas?

#

I should have variables on everythinng

#

Should I send you a pic like that other guy?

#

local PhysicsService = game:GetService("PhysicsService")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local events = ReplicatedStorage:WaitForChild("Events")
local spawnTowerEvent = events:WaitForChild("SpawnTower")

local tower = {}

function FindNearestTarget(newTower)
local maxDistance = 20
local nearestTarget = nil

for i, target in ipairs(workspace.Mobs:GetChildren()) do
    local distance = (target.PrimaryPart.Position - newTower.PrimaryPart).Magnitude
    if distance < maxDistance then
        nearestTarget = target
        maxDistance = distance
    end
end
#

oh shoot

#

Alr

carmine drift
#

you arae doing target.PrimaryPart.Position - newTower.PrimaryPart

#

PrimaryPart is a instance

#

not a vector 3

lime sequoia
#

oh

#

So I basically replace PrimaryPart with HumanoidRootPart?

#

Or vector 3

#

I'm not very good with instances.

#

I swapped all of them to HumanoidRootPart

#

Now it says this: ServerScriptService.Main.Tower:57: ServerScriptService.Main.Tower:34: attempt to index nil with 'Humanoid'

#

Any Ideas

frosty deltaBOT
#

studio** You are now Level 2! **studio

lime sequoia
#

So

#

How should I include Vector 3

#

Can someone help me