Before I go in depth about my current problems, I’ll explain my problem I’m having.
I’m trying to make a model that doesn’t revolve around humanoid parts and is anchored while also being able to take damage from attacks. Basically, I’m trying to make a eyeball that stays in the air and attacks players while being able to take damage from other player’s attacks.
Now this is where my problem comes in. Here’s the heriarchy of the model.
Inside Welder
, it contains 6 weld constraints that connect to unanchored parts and is anchored on purpose. The unanchored parts are the ones that aren’t the following: Laser, Welder
. While the parts do stay in air, it results in the humanoid not being able to take damage and that’s not a result I want, as I want the model to take damage while being in air and being anchored by one part that keeps the model afloat while still being able to be hit my other player’s tools with attacks. I don’t know what to do here, as I know for a fact that humanoids can’t take damage if they aren’t at LEAST moving a slight bit or aren’t anchored, which is not what I want.
In basic terms, I’m trying to make a enemy eyeball that attacks players while being able to take damage and stay in air without having to be on the ground, unanchored just so it can take damage. That is what I’m trying to do that isn’t working out so well.
The most important script that controls the eyeball that should be worth noting is this, since it might be a alternative to what I’m trying to propose as a possible solution. Click here if you want to see it.
Click to see script
local parent = script.Parent
local function nearestHumanPos(origin: Vector3) : Vector3? --ALTERNATE, FOR NPCS
local nearestPosition: Vector3 = nil;
local smallestDistance: number = 15000; -- DISTANCE
for _, human in workspace:GetDescendants() do --GETTING PLAYERS
--print("ACTIVE")
if human.Name ~= "Souls" then
if human.Name ~= parent.EnemyOwner.Value then
if human.ClassName == "Model" then
if human:FindFirstChild("NPCTAG") == nil then
local hrp = human:FindFirstChild("HumanoidRootPart")
if hrp then
local distance = (hrp.Position - origin).Magnitude -- TRACKING PLAYER HUMANOID
if distance < smallestDistance then
smallestDistance = distance;
nearestPosition = hrp.Position;
end
end
end
end
end
end
end
return nearestPosition
end
while true do
local nhp = nearestHumanPos(parent:GetPrimaryPartCFrame().Position)
if nhp then
parent.Welder.Anchored = false
parent:SetPrimaryPartCFrame(CFrame.new(parent:GetPrimaryPartCFrame().Position, nhp))
elseif nhp == nil then
parent.Welder.Anchored = true
end
task.wait()
end
--This is the same script that I was given by someone by the name of "PhoenixRessusection" on DevForum.
--No intent to slander, I'm just crediting the original script writer.
--Also worth noting, this script is a modified version of that script, designed for targetting humanoids (players, NPCS.)
--If you are having thoughts about why I made the "Welder" part turn unanchored, it's because I was going to make the eyeball float above players,
--however I didn't know how to do so even with the AimScript I was provided, so the script isn't finished.
What do I need to do here? If anyone would like to help, please do! I haven’t been able to do anything that gets to do a good amount of progress at fixing this.