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!
A simplistic boat system. -
What is the issue? Include screenshots / videos if possible!
The system I’ve developed thus far works well enough until a secondary player approaches the driver, then the boat insists on flinging itself as far away as humanly possible.
https://medal.tv/games/roblox/clips/8Vw4okZtQDDnH/d1337G0Fu5TA?invite=cr-MSxZVXMsMzM4Nzk1OSw (Thanks icke.) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve attempted to set NetworkOwnership and disable player collisions with each other entirely as potential solutions, both of which failed. I have searched the Developer Hub with lack of success.
Code:
local boat = script.Parent
local boatDriverSeat = boat.Driver
local steerConnect = nil
local throttleConnect = nil
boat.Union.BodyAngularVelocity.MaxTorque = Vector3.new(0, boatDriverSeat.Torque, 0)
boat.Union.BodyVelocity.MaxForce = Vector3.new(boatDriverSeat.MaxSpeed, boatDriverSeat.MaxSpeed, boatDriverSeat.MaxSpeed)
boatDriverSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
local driver = boatDriverSeat.Occupant
if not driver then
print("Sad!")
boatDriverSeat:SetNetworkOwner(nil)
boat.Union:SetNetworkOwner(nil)
steerConnect:Disconnect()
throttleConnect:Disconnect()
else
local player = game:GetService("Players"):GetPlayerFromCharacter(driver.Parent)
if player then
boatDriverSeat:SetNetworkOwner(nil)
boat.Union:SetNetworkOwner(nil)
end
steerConnect = boatDriverSeat:GetPropertyChangedSignal("Steer"):Connect(function()
print(boatDriverSeat.Steer)
boat.Union.BodyAngularVelocity.AngularVelocity = Vector3.new(0, (-1 * boatDriverSeat.Steer) * boatDriverSeat.Torque * boatDriverSeat.TurnSpeed, 0)
end)
repeat -- Plan on switching to VelocityLine
task.wait(.1)
boat.Union.BodyVelocity.Velocity = boat.Union.CFrame:VectorToWorldSpace(Vector3.new(boatDriverSeat.Throttle * boatDriverSeat.MaxSpeed,0,0))
until not boatDriverSeat.Occupant
end
end)