So the player is driving a car, it enters a certain region, the player gets unseated and the car gets deleted. after this the player gets anchored and set to a cframe position, there an idle animation plays. After this when the player exits from this state I unanchor the player and place it at another CFrame position. At this point the players movement acts really weirdly and i can only slide around. the normal movement is gone, when i jump i can change directions and such but not when normally.
Server function
local function removePlayerFromGarage(player, garage)
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Restore movement
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
-- Unanchor and teleport to exit
-- Server
humanoidRootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
humanoidRootPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
character.PrimaryPart.CFrame = garage:FindFirstChild("ExitPoint").CFrame + Vector3.new(0, 3, 0)
humanoidRootPart.Anchored = false
end
local function placePlayerInGarage(player, garage)
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
character.PrimaryPart.CFrame = garage:FindFirstChild("CharacterPart").CFrame + Vector3.new(0, 0, 0)
humanoidRootPart.Anchored = true
-- Disable default anims
-- Play custom idle
local idleAnim = Instance.new("Animation")
idleAnim.AnimationId = "rbxassetid://118660748409131"
local animTrack = animator:LoadAnimation(idleAnim)
animTrack.Looped = true
animTrack:Play()
return animTrack, animScript -- return so you can stop/re-enable later
end
** You are now Level 1! **