The titles a little vague, my apologies I didn't know how to word it. Basically, I'm creating a boss, and while the player is within 50 studs of the boss it will move towards the player constantly, this works fine as well as the attacks (I don't want to use pathfinding, so I'm using :MoveTo()). The issue is that when the boss respawns if the player is already within 50 studs the boss will sit there dormant. Here is the code I'm using to do this:
local Found = false
local B1 = false
local attacking = false
while wait(1) do
local DBMpos = workspace:FindFirstChild("CaptainTennileImposter").HumanoidRootPart.Position
local PlayerPos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
local magnitude = (DBMpos - PlayerPos).Magnitude
--Make sure he's alive
if workspace:FindFirstChild("CaptainTennileImposter").Humanoid.Health > 0 then
--If the players close then he'll move
if magnitude <= 50 then
if B1 then
if (DBMpos - PlayerPos).Magnitude <= 5 then
game.ReplicatedStorage.BossReps.DBMAttack:FireServer()
end
elseif not B1 then
B1 = true
game.ReplicatedStorage.BossReps.InDarkBlueMoon:FireServer(game.Players.LocalPlayer)
end
else
B1 = false
end
end
end
I originally had it at wait() but it ran better to wait(1). What can I do to make it so that If the boss respawns and the player is within the 50 studs it will move? I have a print statement setup in the server side to detect when the player first triggers movement, but this doesn't fire when the player starts within 50 studs of the boss.

4 comments
the script looks completely fine to me. are you resetting B1 to false after it dies?
also, your remote events are completely backwards. you should be doing 100% of this on the roblox server, this could get hacked in an instant. they can just change the magnitude to always be out of range... or not fire remotes at all.
Ok, so how would I get the player in the sever script? Would I have to use OnPlayerAdded?
I changed it to .PlayerAdded and it all runs from the server script now