New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How I resolve bad view from Server w/ BodyVelocity?

Asked by
Diltz_3 75
3 months ago

Hello! I've created my own plane system but when I use special mode. This anchors the plane and set maxForce of BV to 0,0,0 and set maxTorque to BG to 0,0,0

But when I stand on part this is normal from client view but others see it like i'm flying around plane

Client View: http://prntscr.com/o0mlhs

Server View: http://prntscr.com/o0mlma

How do I fix that or this another roblox bug?

Code:

local Stats = script.Parent.Parent:WaitForChild("Stats")

local CruiseRE = Instance.new("RemoteEvent",script.Parent.Parent)
CruiseRE.Name = "CruiseRE"

CruiseRE.OnServerEvent:Connect(function(Player)
    --if Stats.Speed.Value < 200 then return end

    if Stats.Anchored.Value == false then
        if Stats.Cruising.Value == false then
            Stats.Cruising.Value = true
            script.Parent.Anchored = true
            BodyGyro.MaxTorque = Vector3.new(0,0,0)
            BodyVelocity.MaxForce = Vector3.new(0,0,0)
            wait()
            script.Parent.Velocity = Vector3.new(0,0,0)
            script.Parent.RotVelocity = Vector3.new(0,0,0)
        end
    end
end)

BV - BodyVelocity BG - BodyGyro

1 answer

Log in to vote
0
Answered by 3 months ago

Here's how I believe this has happened:

  • The client has network ownership over the plane. (This is why, as the client flies the plane, they see the plane changing immediately (like an extension of their character) rather than lagging a second behind. This is how controls are responsive instead of taking ~1 second to take effect.)
  • Now the server anchors the plane. Let's pretend the plane is at position 10 and was travelling in a positive direction at +2/sec. If it took half a second for the player's request to get to the server, then note that the client's plane is already at position 11 (since it's been informing the server of where the plane is supposed to be). Note that the plane was at position 9 when the player initiated the request for it to be anchored.
  • By the time the client receives the server's replication that the plane is anchored, the plane is now at position 12.
  • (Probably a bug) Roblox doesn't update the plane's position on the client (probably since the plane is anchored)
  • The client's character is standing on top of a plane at position 12, but everyone else sees the plane is at position 10. The client's character doesn't fall because the client is in complete control of the client's character physics. This would explain your screenshots.

To resolve this problem, you might:

  • Use BodyGyro and either BodyPosition or BodyVelocity to keep the plane in place without anchoring it. You could optionally anchor the plane after a wait(). You might want to set the NetworkOwner to the server before the 'wait()'. (This option might cause the client's character to teleport (which would be jarring) or simply fall into the abyss.)
  • Simply anchor the plane client-side when the client requests this "cruise" mode. If the inconsistency persists (which it might - the client might not update the server because the plane is anchored), have the client also sends the plane's exact position (or cframe) to the server along with the request to anchor it. After that, all inconsistencies should disappear.
Ad

Answer this question