-
What do you want to achieve? When a player falls off a cliff, and collides with a big invisible block, I want to teleport (or move) the player back to a specific spot on the cliff. However, I want to do this with the player having no momentum. So player velocity would be reset to zero.
-
What is the issue? When the player falls, then gets moved (teleported) back to the cliff top, the player inherits the movement, momentum, or velocity, and then sometimes flings into the air because of this. I do not want the player to fling. I want the player to appear at the cliff top at a non falling momentum - just normal at rest.
-
What solutions have you tried so far? I’ve looked for solutions. I am having trouble phrasing the question to get results that help me.
Please see below code I am using. Thank you.
local part = script.Parent
local damage = 25
local DB = false
local OuchSFXEvent = game.ReplicatedStorage.Remotes.OuchSFXEvent
local function teleport(bodyPart)
if DB == false then
DB = true
local humanoid = bodyPart.Parent:FindFirstChild('Humanoid')
if humanoid then
bodyPart.Parent.HumanoidRootPart.CFrame = script.Parent.Parent.SpawnLocation.CFrame
if humanoid.Health > 0 then
humanoid:TakeDamage(damage)
local player = game:GetService("Players"):GetPlayerFromCharacter(bodyPart.Parent)
OuchSFXEvent:FireClient(player)
end
end
wait(.5)
DB = false
end
end
part.Touched:Connect(teleport)