Hi so I’m testing out some things that parts have and I found getClosestPointOnSurface and thought I would try it. It’s good and it works but I just want the movement of the red part to be delayed by 0.25 seconds.
Code:
local RunService = game.findService(game, "RunService")
local Players = game.findService(game, "Players")
local Workspace = game.findService(game, "Workspace")
local TweenService = game.findService(game, "TweenService")
local Player = Players.LocalPlayer
local Part = script.Parent
while true do
while Player.Character or Player.CharacterAdded.wait(Player.CharacterAdded) do
Workspace.Moving.Position = Part.getClosestPointOnSurface(Part, Player.Character.getPivot(Player.Character).Position)
RunService.RenderStepped.wait(RunService.RenderStepped)
end
end
You’ll probably need to swap out the while loop for a runservice connection with a wait, like this:
local RunService = game.findService(game, "RunService")
local Players = game.findService(game, "Players")
local Workspace = game.findService(game, "Workspace")
local TweenService = game.findService(game, "TweenService")
local Player = Players.LocalPlayer
local Part = script.Parent
RunService.Heartbeat:Connect(function()
if Player.Character then
local Position = Part.getClosestPointOnSurface(Part, Player.Character.getPivot(Player.Character).Position)
task.wait(0.25)
Workspace.Moving.Position = Position
end
end)
You can also swap Heartbeat for RenderStepped, but that’s up to you
I just realized you just didn’t use the colon notation but instead opted to use the dot notation. Very uncanny sight to see im ngl… What do you gain from this?
This isn’t the first time people have talked about my scripting like that. People also have mentioned that I don’t capitalize the first word in the things but use lowercase even though most people capitalize it
could you send a video? it works for me. If by “teleport” you mean the fact that the part jitters ever so slightly, that will be because of slight inaccuracy of task.wait() function. There may be a workaround with Tweening or something, i’ll look into it.