local Hitbox = Instance.new("Part",workspace.VFxFolder)
Hitbox.Material = Enum.Material.ForceField
Hitbox.Size = Vector3.new(5,5,raycastresult.Distance)
Hitbox.CanCollide = false
Hitbox.Anchored = true
Hitbox.CFrame = CFrame.new((Origin + raycastresult.Position)/2,Origin)
Hitbox.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
if part.Parent.Name ~= character.Name then
character:PivotTo(part.Parent.PrimaryPart.CFrame * CFrame.new(0,0,-3))
end
else
character:PivotTo(CFrame.new(raycastresult.Position) + Vector3.new(0,2,0))
end
end)
This is my script
Basically I want to teleport at behind player when player hit hitbox but if not then teleport to mouse position