https://youtu.be/3FkwIT-2Em4
ネットワークオーナー(キャラのモデル内に挿入)
local rpart = workspace["11ishisotsu"].Ishisotsu:FindFirstChild("HumanoidRootPart")
rpart:SetNetworkOwner(nil)
リモコンのスクリプト
local rimo = script.Parent
local sotsu = workspace["11ishisotsu"]:WaitForChild("Ishisotsu").Humanoid
local pathfindingservice = game:GetService("PathfindingService")
local value1 = script.Parent.Value
local function help()
rimo.Enabled = false --リモコンを使えなくする(段差にキャラが突っかかってしまう場合はこれがあるといい)
rimo.Handle["Light click off and on sound"]:Play()
value1.Value = true --クリック直後、trueにする
task.wait(1)
value1.Value = false
local rpart = workspace["11ishisotsu"].Ishisotsu.HumanoidRootPart
local path = pathfindingservice:CreatePath({
AgentRadius = 3 --キャラが通れる幅。数字が大きいほど大きな幅を選ぶようになる。
})
path:ComputeAsync(rpart.Position,rimo.Handle.Position) --キャラの体の位置がスタート、リモコンの位置をゴールにし道順を作る。
if path.Status == Enum.PathStatus.Success then --道順を作れたら
for _, waypoint in ipairs(path:GetWaypoints())do
if value1.Value == true then --もし到着前にクリックされていたら
print("break") break end --歩き終える
if waypoint.Action == Enum.PathWaypointAction.Jump then
sotsu.Jump = true
end
sotsu:MoveTo(waypoint.Position) --道順に沿って動く
local arukiawari = sotsu.MoveToFinished:Wait() --ゴールにたどり着くまで待つ
if not arukiawari then --8秒経ってもたどり着いていなかったら
rimo.Enabled = true --リモコンを使えるようにする
break end --ループをぶっ壊す!
end
else print("NoPath") --道順を作れなかったよ;_;
end
rimo.Enabled = true --すべて終えたらリモコンを使えるようにする
end
rimo.Activated:Connect(help) --リモコンをクリックしたらhelpを実行