I’m a roblox scripter for almost a year now and have encountered an issue when trying to make a moving snowboard for my game. I use a linear velocity in plane mode and alter the X axis to go forward and accelerate and the Y axis to slide from side to side (I dont need it to go backwards). However, when at high speed, sliding from side to side makes the snowboard turn (as you can see towards the end of the video). Is there any way that I can make it stay in the same orientation the whole ride?
-
What do you want to achieve? A working snowboard that doesnt turn with the character when moving.
-
What is the issue? The snowboard is turning when sliding from side to side at high speed.
-
What solutions have you tried so far? I’ve tried making the snowboard massless, and I’ve changed from linearvelocity vector to plane, neither of these solving the solution.
Server script:
local snowboard = game.Workspace.Snowboard
local seat = snowboard.Seat
local RE = game.ReplicatedStorage.RemoteEvents.SideMoving
local FE = game.ReplicatedStorage.RemoteEvents.ForwardEvent
local speed
local basespeed
local maxspeed
local accelMulti
local slideSpeed
seat.ChildAdded:Connect(function()
char = seat:WaitForChild("SeatWeld").Part1.Parent
HRP = char:WaitForChild("HumanoidRootPart")
if char then
warn(HRP)
att = Instance.new("Attachment", HRP)
att.Name = "Att"
linearVelocity = Instance.new("LinearVelocity", att)
linearVelocity.Name = "LinearVelocity"
linearVelocity.Attachment0 = att
linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Plane
linearVelocity.SecondaryTangentAxis = Vector3.new(0,0,1)
linearVelocity.PlaneVelocity = Vector2.new(5,0)
speed = att.LinearVelocity.PlaneVelocity.X
basespeed = 5
maxspeed = 10000000000
accelMulti = 10000
slideSpeed = 50000
end
end)
RE.OnServerEvent:Connect(function(player, direction)
linearVelocity.PlaneVelocity = Vector2.new(linearVelocity.PlaneVelocity.X,direction*slideSpeed)
end)
FE.OnServerEvent:Connect(function(player, val)
if val == "Acceling" and speed < maxspeed then
att.LinearVelocity.PlaneVelocity += Vector2.new(2*accelMulti,0)
speed = att.LinearVelocity.PlaneVelocity.X
elseif val == "Decceling" and speed > basespeed then
att.LinearVelocity.PlaneVelocity -= Vector2.new(1,0)
speed = att.LinearVelocity.PlaneVelocity.X
end
end)
Client script:
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character
local RE = game.ReplicatedStorage.RemoteEvents.SideMoving
local FE = game.ReplicatedStorage.RemoteEvents.ForwardEvent
local direction = 0
local accel = 0
while wait() do
if char.HumanoidRootPart:FindFirstChild("Att") then
local animation = Instance.new("Animation", char) -- cream animatia
--animation.AnimationId = "http://www.roblox.com/asset/?id=14362149551"
--https://www.roblox.com/library/14363735107/LiveActionTest1
--14363812307 liveactiontest2
--14363835692 liveactiontest3
animation.AnimationId = "http://www.roblox.com/asset/?id=14363835692" -- ii setam id-ul
local hum = char:WaitForChild("Humanoid") -- definim humanoidul
local wave = hum:LoadAnimation(animation) -- folosim humanoidul pt a incarca animatia
wave.Looped = true -- o facem sa mearga la infinit
wave:Play() -- ii dam play la animatie
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
warn("ClientSide")
direction += 1
RE:FireServer(direction)
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
--warn("ClientSide")
direction -= 1
RE:FireServer(direction)
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A then
direction -= 1
RE:FireServer(direction)
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A then
--warn("ClientSide")
direction += 1
RE:FireServer(direction)
end
end)
-- PT ACCEL MAI JOS
while true do
if UIS:IsKeyDown(Enum.KeyCode.W) then
FE:FireServer("Acceling")
else
FE:FireServer("Decceling")
end
wait(.5)
end
end
end
Video Link: 2023-08-08 21-35-42