Hello. I made floaties, but whenever I sit on it, it just drowns down and not stable. Here is a video:
https://streamable.com/gov7s5
Here are all my script:
First script (Server Script):
local proximity = script.Parent;
local function triggered(player)
local character = player.Character;
local humanoid = character.Humanoid;
local animation = script.Animation;
local track = humanoid:LoadAnimation(animation);
track:Play()
wait(0.1)
local seat = script.Parent.Parent.Seat;
seat:Sit(character.Humanoid)
game.ReplicatedStorage.FloatieThrust.ClientCommunication:FireClient(player, script.Parent.Parent)
script.Parent.Parent:SetNetworkOwner(player)
script.Parent.Parent.CurrentDriver.Value = player
repeat wait()
until script.Parent.Parent.Seat.Occupant == nil
if player then
track:Stop()
else
end
script.Parent.Parent.BodyVelocity.Velocity = Vector3.new(0, 0, 0)
script.Parent.Parent.CurrentDriver.Value = nil
end;
proximity.Triggered:Connect(triggered)
while wait() do
if script.Parent.Parent.Seat.Occupant then
script.Parent.Enabled = false
else
script.Parent.Enabled = true
end
end
Second Script (Local Script):
local remoteEvent = game.ReplicatedStorage.FloatieThrust.ClientCommunication;
local function client_Event(floatie)
repeat wait()
local userInputService = game:GetService("UserInputService");
userInputService.InputBegan:Connect(function(input, isTyping)
if isTyping then return end;
if input.KeyCode == Enum.KeyCode.W then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.Z, -3, floatie)
elseif input.KeyCode == Enum.KeyCode.S then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.Z, 3, floatie)
elseif input.KeyCode == Enum.KeyCode.A then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.X, -3, floatie)
elseif input.KeyCode == Enum.KeyCode.D then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.Z, 3, floatie)
end
end)
userInputService.InputEnded:Connect(function(input, isTyping)
if isTyping then return end;
if input.KeyCode == Enum.KeyCode.W then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.Z, 0, floatie)
elseif input.KeyCode == Enum.KeyCode.S then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.Z, 0, floatie)
elseif input.KeyCode == Enum.KeyCode.A then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.X, 0, floatie)
elseif input.KeyCode == Enum.KeyCode.D then
game.ReplicatedStorage.FloatieThrust.Thrust:FireServer(Enum.Axis.Z, 0, floatie)
end
end)
until floatie.CurrentDriver.Value ~= game.Players.LocalPlayer
return
end;
remoteEvent.OnClientEvent:Connect(client_Event)
Third Script (Server Script)
local remoteEvent = game.ReplicatedStorage.FloatieThrust.Thrust;
local function server_Event(player, axis, valueAxis, floatieInstance)
local finalVelocity = nil;
local finalMaxForce = nil;
if axis == Enum.Axis.X then
finalVelocity = Vector3.new(valueAxis, 0, floatieInstance.BodyVelocity.Velocity.Z)
finalMaxForce = Vector3.new(300, 0, floatieInstance.BodyVelocity.MaxForce.Z)
elseif axis == Enum.Axis.Z then
finalVelocity = Vector3.new(floatieInstance.BodyVelocity.Velocity.X, 0, valueAxis)
finalMaxForce = Vector3.new(floatieInstance.BodyVelocity.MaxForce.X, 0, 300)
end
local tweenService = game:GetService("TweenService");
local tweenInfo = TweenInfo.new(2);
local goal = {
Velocity = finalVelocity;
MaxForce = finalMaxForce
};
tweenService:Create(floatieInstance.BodyVelocity, tweenInfo, goal):Play()
end
remoteEvent.OnServerEvent:Connect(server_Event)
Even before the character sits on it, it is unstable and rotating in the water.