Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

MoveTo() not moving to exact point, possibly affected by humanoid size?

Asked by 5 years ago

This problem didn't come up until recently and have been ripping my hair out for about two months. SO, I have a large humanoid (~1.4x size) with a walk speed of 120. The humanoid is supposed to run to the nearest player and collide with them, knocking them over using trip, recently it began to run to the player then stop a few studs away, then inching closer until eventually bumping the player. At first I thought it was a problem with moveTo() possibly with an update but after testing 5 different clean slates of humanoids, it seems it works perfectly when the humanoid is not resized, but resizing at all makes them stop short. I've tried resizing with both model size and Humanoid:BodyHeightScale etc. The issue can be seen in my place (rear left corner of map from spawn). Scripts: ```lua math.randomseed(tick()) local p = script.Parent local random = math.random local lastTarget,target = nil

local game_players = game.Players local function findNearestPlayer(pos) local closestPlayer local distance = 320 local closestDistance = distance local playerList = game_players:GetPlayers() for i=1, #playerList do local player = playerList[i] -----CHECKS EVERY PLAYER IN GAME------ https://medium.com/@RBX_Crazyman32/battle-of-the-loops-c001bcb4961c if player.Character then local human = player.Character:FindFirstChild("Humanoid") if human then if human.Health > 0 then local root = player.Character:FindFirstChild("HumanoidRootPart") local playerDist = (root.Position - pos).magnitude if playerDist < distance then if closestPlayer then if playerDist < closestDistance then closestDistance = playerDist closestPlayer = root end else closestDistance = playerDist closestPlayer = root end end end end end end lastTarget = closestPlayer return closestPlayer end

while true do target = findNearestPlayer(p.HumanoidRootPart.Position) if target then p.Humanoid:MoveTo(target.Position, target) end wait(random(100,500)*0.01) end Script in HumanoidRootPart or UpperTorsolua script.Parent.Touched:connect(function(hit) if not (hit) then return end if not (hit.Parent) then return end if not (hit.Parent:FindFirstChild("Humanoid")) then return end if not (hit.Parent.Humanoid.Health > 0) then return end

hit.Parent.Humanoid:TakeDamage(7.5)
hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed + 15
if not hit.Parent:FindFirstChild("physics") then
    local newscript = script.physics:Clone()
    newscript.Parent = hit.Parent
    newscript.Disabled = false
end

end) Disabled localscript child of last script called "physics"lua local h = script.Parent.Humanoid

if h and h.Health > 0 then h:ChangeState'Physics' end wait(math.random(280,400)*0.01) if h and h.Health > 0 then h:ChangeState'GettingUp' end script:Destroy() ``` I'm really hoping a solution can be found for this, thanks in advance.

1
I am not too great of a programmer but after the first month of hair pulling I usually resort to finding a way around the problem instead of actually fixing it (assuming it is a roblox glitch there may not be much else you can do). OBenjOne 190 — 5y
0
something I could think of off the top of my head is telling the humanoid to run a few studs past the character, and telling it to stop after hitting the character. OBenjOne 190 — 5y
0
I assume an experienced programmer could develop some sort of program (using rays?) to find a point an adequate distance behind the character although I understand that this might interfere with any pathfinding system you have set up. OBenjOne 190 — 5y
0
Try looking up CFrame, I've used that for moving a character. Just a suggestion. superawesome113 112 — 5y

Answer this question