Hello, I am making an air hockey game in roblox, and the movement of the paddle in my game is through a body position. And in the game, at first the body position acts to elastic. but after shaking the paddle for a bit; it fixes itself. If anybody needs more information or screenshots to help solve my issue, I’ll gladly provide. if anybody has a solution for this it would be great. thanks in advance!
-quackywhackity.
game.ReplicatedStorage.MovePuck.OnServerEvent:Connect(function(Player,Hit)
local AirTable = workspace.Table
local PlayerColor
if AirTable.Colors.Blue.Value == Player.Name then
PlayerColor = "Blue"
elseif AirTable.Colors.Red.Value == Player.Name then
PlayerColor = "Red"
end
if PlayerColor then
local Position = Vector3.new(Hit.X,4.354,Hit.Z)
local PlayArea = AirTable.PlayingArea["Collision"..PlayerColor]
if Position.X > (PlayArea.Position.X + (PlayArea.Size.X/2)) then
Position = Vector3.new((PlayArea.Position.X + (PlayArea.Size.X/2)) , Position.Y,Position.Z)
elseif Position.X < (PlayArea.Position.X - (PlayArea.Size.X/2)) then
Position = Vector3.new((PlayArea.Position.X - (PlayArea.Size.X/2)) , Position.Y,Position.Z)
end
if Position.Z > (PlayArea.Position.Z + (PlayArea.Size.Z/2)) then
Position = Vector3.new(Position.X , Position.Y,(PlayArea.Position.Z + (PlayArea.Size.Z/2)) )
elseif Position.Z < (PlayArea.Position.Z - (PlayArea.Size.Z/2)) then
Position = Vector3.new(Position.X , Position.Y,(PlayArea.Position.Z - (PlayArea.Size.Z/2)) )
end
AirTable.Paddles[PlayerColor.."_Paddle"].BodyPosition.Position = Position
end
end)