I’m trying to teleport the player in front 10 studs but as you can see, it works sometimes and is delayed sometimes. Is there a fix or solution to this problem?
2022-09-19 19-59-41.wmv (4.6 MB)
Could you paste your script? We can’t fix the problem without seeing your code.
1 Like
yep, my bad
function newPart(hrp, length)
local newPart = Instance.new("Part")
newPart.Parent = workspace
newPart.Size = Vector3.new(1, 1, length)
newPart.CanCollide = false
newPart.Anchored = true
local halfOfLength = length/2
newPart.CFrame = hrp.CFrame * CFrame.new(0, 0, -halfOfLength)
newPart.Transparency = .8
end
remoteEvent.OnServerEvent:Connect(function(player, mouseHit)
local hrp = player.Character.HumanoidRootPart
print(mouseHit.LookVector)
local currentPivot = hrp:GetPivot()
local length = 10
newPart(hrp, length)
hrp:PivotTo(currentPivot * CFrame.new(0, 0, -length))
end)
Try this:
local function newPart(hrp, length)
local halfOfLength = length/2
local newPart = Instance.new("Part")
newPart.Size = Vector3.new(1, 1, length)
newPart.CFrame = hrp.CFrame * CFrame.new(0, 0, -halfOfLength)
newPart.Transparency = .8
newPart.CanCollide = false
newPart.Anchored = true
newPart.Parent = workspace
end
local runService = game:GetService("RunService")
remoteEvent.OnServerEvent:Connect(function(player, mouseHit)
local hrp = player.Character.HumanoidRootPart
print(mouseHit.LookVector)
local length = 10
newPart(hrp, length)
hrp:PivotTo(hrp.CFrame + hrp.CFrame.LookVector * length)
end)
1 Like