I need help with my script here is a picture of it:
im following gnomecode tutorial to make a tower defense game, this is from part 4 beggining
You are not referencing a BasePart with Position property inside the enemy. If the enemy model has PrimaryPart, you can use enemy.PrimaryPart.Position or any other part inside the model.
can u just tell me what to write or do because i suck at scripting
I do not know how your enemy looks like, but I imagine it is a basic rig.
You have to change your code to the following:
local tower = script.Parent
local enemy = workspace.Enemy
local distance = ( tower.Position - enemy.HumanoidRootPart.Position ).magnitude
print(distance)
If this code works, please select my post as the solution to your problem.
the enemy is just a part, its for testing
I don’t think it’s the enemy, since the error mentions an instance called Workspace.GnomeNormal
, but the enemy is just Workspace.Enemy
Try doing
local distance = (tower.HumanoidRootpart.Position - enemy.Position).Magnitude
instead.
Ah, then the code will be so:
local tower = script.Parent
local enemy = workspace.Enemy
local distance = ( tower.HumanoidRootPart.Position - enemy.Position ).magnitude
print(distance)
isnt the problem “tower” or is it enemy?
it works
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.