What do you want to achieve? Keep it simple and clear!
Make the monster go behind the player
What is the issue? Include screenshots / videos if possible!
Monster does not go behind the player!!!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried putting the position as the negative lookvector i tried this before and it worked now it doesn’t anymore
local debounce = false
script.Event.Event:Connect(function()
local nearestplr
local maxrange = 100
while task.wait(5) do
if game.Workspace.Chasing.Value == true then
if debounce == false then
debounce = true
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character and v.Character.Humanoid.Health > 0 then
local magnitude = (v.Character.PrimaryPart.Position - game.Workspace.Fire.Position).Magnitude
if magnitude <= maxrange then
nearestplr = v.Character
end
end
end
kill(nearestplr)
end
else
break
end
end
end)
function kill(nearest)
if nearest and nearest.Humanoid.Health > 0 then
print(nearest.Name)
local Monster = game.ServerStorage.Monster:Clone()
local part = Instance.new("Part")
local plr = game.Players:GetPlayerFromCharacter(nearest)
part.Parent = game.Workspace
part.Position = plr.Character.PrimaryPart.CFrame.LookVector * 1
print(tostring(plr.Character.HumanoidRootPart.CFrame.LookVector * 1))
part.Anchored = true
part.Name = "daniel"
Monster.Parent = game.Workspace
Monster.HumanoidRootPart.Smoke.Enabled = true
nearest.Humanoid.WalkSpeed = 0
Monster:MoveTo(part.Position)
task.wait(3)
Monster.HumanoidRootPart.Smoke.Enabled = false
task.wait(5)
local anim = Monster.Humanoid:LoadAnimation(Monster.Animation)
anim:Play()
anim.Stopped:Wait()
nearest.Humanoid.Health = 0
Monster:Destroy()
debounce = false
end
end
Which section of the code calls the event? This may cause the problem, because if that event does not get called, nearest will be nil and “kill()” would never run
I think this code would work (It worked on my end)
local Part = script.Parent
local Rig = game.Workspace.Rig
Rig.HumanoidRootPart.CFrame = Part.CFrame - (Part.CFrame.LookVector.Unit * 10) + Vector3.new(0, 2.2, 0) – Adding the 2.2 studs higher ensures that the humanoidRootPart doesn’t sink through the ground
Edit: You will need to fix this code to fit yours, if you are having trouble with that, ask me and I will make a theoretically working version of your code