So i have a flare in my game, i want if the player shots it, and the monster is in the 250 studs distance the monster would run to the flare.
In the monster
local PathingModule = require(script.Parent.Parent.PathfindingService)
local MainPath = PathingModule.new(script.Parent.Parent)
local character = script.Parent.Parent
local MaxDistance = script.Parent.Parent.Distance.Value
script.FlareEvent.Event:Connect(function(Tool)
local DisMagnitude = (Tool.Handle.Position - character.Position).magnitude
if DisMagnitude < MaxDistance then
print("Rake was in the distance off the flare")
local RandomTing = math.random(1,2)
if RandomTing == 1 then
character.Head.Rake_Scream:Play()
elseif RandomTing == 2 then
character.Head.Rake_Scream2:Play()
end
character.Inactive.Value = true
MainPath:Run(Tool.Handle.Position)
MainPath.Completed:Wait()
character.Inactive.Value = false
end
end)
In the client
local Tool = script.Parent
workspace.Rake.RakeMainAI.MoveAwayFromFlare.FlareEvent:Fire(Tool)