You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to clear waypoints after moving force stops my pathfind (Not a problem and im not doing it roblox is) -
What is the issue? Include screenshots / videos if possible!
For some reason waypoints just seem to fuse into my new path and make it messy (Go back and forth randomly) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Ive tryed Clearing them but all ive goten to is that they fuse for some reason im not sure why
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This script is still a WIP and It looks scary, I also use knit but that shouldnt matter, here is the full thing
local Knit = require(game:GetService("ReplicatedStorage").Library.Knit)
local player : Player = Knit.Player
--[[Services]]--
local cs = game:GetService("CollectionService")
local rs = game:GetService("ReplicatedStorage")
local modules = rs:WaitForChild("SharedModules")
local configs = rs:WaitForChild("Configs")
local playerScripts = player.PlayerScripts
local ts = game:GetService("TweenService")
local Uis = game:GetService("UserInputService")
local PathfindingService = game:GetService("PathfindingService")
--[[Modules]]--
local format = require(modules:WaitForChild("FormatNumber"))
local message = require(modules:WaitForChild("Messages"))
local promise = require(rs:WaitForChild("Library"):WaitForChild("Promise"))
local types = require(modules:WaitForChild("Types"))
local stateManager = require(modules:WaitForChild("StateManager"))
--[[Configs]]--
local trainingConfig = require(configs:WaitForChild("TrainingConfig"))
--[[Variables]]--
local leaderstats = player:WaitForChild("leaderstats")
local powerValue = leaderstats:WaitForChild("Power") :: NumberValue
local PlayerGUI = game.Players.LocalPlayer.PlayerGui
local PathfindForceStop = false
local Pathfinding = false
Uis.InputBegan:Connect(function(I)
if Pathfinding then
if I.KeyCode == Enum.KeyCode.W or I.KeyCode == Enum.KeyCode.S or I.KeyCode == Enum.KeyCode.A or I.KeyCode == Enum.KeyCode.D or I.KeyCode == Enum.KeyCode.Thumbstick1 then
PlayerGUI.Main.HUD.Auto.AutoTrain.Off.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled = false
PlayerGUI.Main.HUD.Auto.AutoBattle.Off.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoBattle.On.Enabled = false
Pathfinding = false
player.Character:RemoveTag("AutoWalking")
end
end
end)
Uis.TouchMoved:Connect(function()
if Pathfinding then
PlayerGUI.Main.HUD.Auto.AutoTrain.Off.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled = false
Pathfinding = false
end
end)
local function Pathfind(Target)
local path = PathfindingService:CreatePath()
path:ComputeAsync(game.Players.LocalPlayer.Character.HumanoidRootPart.Position, Target)
local waypoints = path:GetWaypoints()
local Waypoint = 0
Pathfinding = true
player.Character:AddTag("AutoWalking")
for i,v in pairs(waypoints) do
if PathfindForceStop == true then
PathfindForceStop = false
player.Character:RemoveTag("AutoWalking")
return
end
Waypoint = i
game.Players.LocalPlayer.Character.Humanoid:MoveTo(v.Position)
game.Players.LocalPlayer.Character.Humanoid.MoveToFinished:Wait()
end
player.Character:RemoveTag("AutoWalking")
end
local function AutoTrainOn(TrainingController)
local AcceptableSpots = {}
for i,v in pairs(trainingConfig) do
if v.Required <= powerValue.Value then
local Stop = false
for I,V in pairs(player:GetAttributes("ActiveTrainingArea")) do
if V == i then
Stop = true
end
end
if Stop == false then
table.insert(AcceptableSpots, v)
end
end
end
local TopSpot = nil
for i,v in pairs(AcceptableSpots) do
if TopSpot == nil then
TopSpot = v
else
if TopSpot.Required <= v.Required then
TopSpot = v
end
end
end
Pathfind(TopSpot.Dummy.Touch.Position)
TrainingController:Train(TopSpot.Dummy)
end
local function AutoBattleOn()
local ClosestWalkTooPoint = nil
local Circles = cs:GetTagged("BattleWalk")
local Closest = nil
local Distance = 0
for i,v in pairs(Circles) do
local distance = (v.Position - player.Character.HumanoidRootPart.Position).Magnitude
print(v, Distance)
if distance <= Distance then
Closest = v
Distance = distance
elseif Distance == 0 then
Closest = v
Distance = distance
end
end
Pathfind(Closest.Position)
end
local function AutoBattleOff()
end
local AutoController = Knit.CreateController{
Name = script.Name;
}
function AutoController:KnitInit()
self.FightingController = Knit.GetController("FightingController")
self.TrainingController = Knit.GetController("TrainingController")
self.TrainingService = Knit.GetService("TrainingService")
-- self.FightingService = Knit.GetService("FightingService")
end
function AutoController:KnitStart()
PlayerGUI.Main.HUD.Auto.AutoTrain.Btn.Activated:Connect(function()
if PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled == false then
PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoTrain.Off.Enabled = false
AutoTrainOn(self.TrainingController)
else
PlayerGUI.Main.HUD.Auto.AutoTrain.Off.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled = false
PathfindForceStop = true
Pathfinding = false
end
if PlayerGUI.Main.HUD.Auto.AutoBattle.On.Enabled == true then
PlayerGUI.Main.HUD.Auto.AutoBattle.On.Enabled = false
PlayerGUI.Main.HUD.Auto.AutoBattle.Off.Enabled = true
AutoBattleOff()
end
end)
PlayerGUI.Main.HUD.Auto.AutoBattle.Btn.Activated:Connect(function()
if PlayerGUI.Main.HUD.Auto.AutoBattle.On.Enabled == false then
PlayerGUI.Main.HUD.Auto.AutoBattle.On.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoBattle.Off.Enabled = false
AutoBattleOn()
else
PlayerGUI.Main.HUD.Auto.AutoBattle.Off.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoBattle.On.Enabled = false
AutoBattleOff()
end
if PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled == true then
PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled = false
PlayerGUI.Main.HUD.Auto.AutoTrain.Off.Enabled = true
PathfindForceStop = true
Pathfinding = false
end
end)
function self:StopTrain()
PlayerGUI.Main.HUD.Auto.AutoTrain.Off.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled = false
end
function self:StopBattle()
PlayerGUI.Main.HUD.Auto.AutoBattle.Off.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoBattle.On.Enabled = false
end
function self:StartTrain()
PlayerGUI.Main.HUD.Auto.AutoTrain.On.Enabled = true
PlayerGUI.Main.HUD.Auto.AutoTrain.Off.Enabled = false
end
end
return AutoController
this is all that really matters tho
local function Pathfind(Target)
local path = PathfindingService:CreatePath()
path:ComputeAsync(game.Players.LocalPlayer.Character.HumanoidRootPart.Position, Target)
local waypoints = path:GetWaypoints()
local Waypoint = 0
Pathfinding = true
player.Character:AddTag("AutoWalking")
for i,v in pairs(waypoints) do
if PathfindForceStop == true then
PathfindForceStop = false
player.Character:RemoveTag("AutoWalking")
return
end
Waypoint = i
game.Players.LocalPlayer.Character.Humanoid:MoveTo(v.Position)
game.Players.LocalPlayer.Character.Humanoid.MoveToFinished:Wait()
end
player.Character:RemoveTag("AutoWalking")
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.