(I’m pretty sure this is the right category to put this topic, if not please correct me so I can change)
Hi everyone!
My little brother gave me the challenge of writing a script, that makes something chase after you, but:
- I can’t use pathfinding
- I can’t use magnitude/distance
- And I can’t change the position/CFrame directly using my code
I’ve tried searching it up but too no luck.
Here’s my script (ignore raycasting for now):
local part = script.Parent
local fireRate = 0.1 -- seconds
while wait(fireRate) do
for i, v in pairs(game.Workspace:GetChildren()) do -- loops through workspace children
local human = v:FindFirstChild("Humanoid")
local hRoot = v:FindFirstChild("HumanoidRootPart")
local head = v:FindFirstChild("Head")
if human and hRoot and head then -- if a game child has a: humanoid, humanoidrootpart, and head then continue
local Raycast1 = Ray.new(part.Position, part.CFrame.LookVector * 10)
local hit = game.Workspace:FindPartOnRayWithIgnoreList(Raycast1, {part})
part.CFrame = CFrame.new(part.Position, hRoot.Position + Vector3.new(0, 15, 0))
if hit then
print("ray found "..hit.Name)
else
print("ray found nothing")
end
end
end
end
How it works is, the part looks above the player, it falls slightly, then it comes back up.
Kind of like a snake but not really lol
He said that it doesn’t go around walls…
DUDE I-
is it even possible to implement pathfinding to this? (following those rules)
If so that might be fun to do as long as it’s not SUPER complicated
why I added raycasting
I thought that maybe if it hit a wall and that the wall’s name isn’t equal to a name of a player
it could somehow go around it?
(I added raycasting and not just a touch event bc I don’t want this to push around unanchored parts by accident)
my question is:
is this possible?
I NEVER turn down a challenge (that’s possible)
(for those who are confused: it’s just a block with a face at the front lol)