So i am making a game in which the player has a sled, and i used a hover script simmilar to a pet script but its really shaky and i dont know why
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player
local playerFolder = Instance.new("Folder")
playerFolder.Name = "playerFolder"
playerFolder.Parent = player
local sledCapacity = Instance.new("NumberValue")
sledCapacity.Name = "sledCapacity"
sledCapacity.Value = 0
sledCapacity.Parent = playerFolder
local sledMaxCapacity = Instance.new("NumberValue")
sledMaxCapacity.Name = "sledMaxCapacity"
sledMaxCapacity.Value = 20
sledMaxCapacity.Parent = playerFolder
local cash = Instance.new("NumberValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = leaderstats
local snow = Instance.new("NumberValue")
snow.Name = "Snow"
snow.Value = 0
snow.Parent = leaderstats
player.CharacterAdded:Connect(function(character)
local sledFolder = Instance.new("Folder")
sledFolder.Name = "sledFolder"
sledFolder.Parent = character
local sled = game.ServerStorage:WaitForChild("SledPart"):Clone()
local snowVisual = game.ServerStorage:WaitForChild("SnowVisual"):Clone()
sled.Parent = sledFolder
local sledAttachment = Instance.new("Attachment")
sledAttachment.Name = "SledAttachment"
sledAttachment.Parent = sled
local weld = Instance.new("WeldConstraint")
weld.Parent = snowVisual
weld.Part0 = snowVisual
weld.Part1 = sled
snowVisual.Parent = sledFolder
local tolerance = 10
while wait(1/60) do -- Adjust the wait time based on your desired frame rate (60 frames per second in this case)
if player and player.Character then
local targetPos = player.Character:WaitForChild("HumanoidRootPart").Position
local sledPos = sled.Position
sled.Position = sledPos:Lerp(targetPos, 0.1)
snowVisual.Position = sled.Position
end
end
end)
end)