Hello! I am trying to make a teleportation using bezier curve.
So basically, when the player triggers the proximityprompt, it’ll fire and event.
And then, theres many stuffs that happens; invisiblity, particles and i want to add a bezier curve when the player gets transported to the position i have set.
But when i play test, all the scripts works fine but the bezier curve just looks crusty and weird.
this is what i expect it to be like:
here’s a vid of how it looks like in game:
https://gyazo.com/840a756b420f1f1cd6d401f235d76147
local script:
local rs = game:GetService("ReplicatedStorage")
local remoteEvent = rs:WaitForChild("Character"):WaitForChild("characterTeleport")
local proximityPrompt = game.Workspace:WaitForChild("book"):WaitForChild("Plane"):WaitForChild("Attachment"):WaitForChild("ProximityPrompt")
local debounce = false
proximityPrompt.Triggered:Connect(function()
remoteEvent:FireServer()
end)
script:
local rs = game:GetService("ReplicatedStorage")
local remoteEvent = rs:WaitForChild("Character"):WaitForChild("characterTeleport")
function fade(v)
for i = 1,20 do
v.Transparency += 0.1
task.wait()
end
end
remoteEvent.OnServerEvent:Connect(function(Player)
local character = Player.Character
if not character then
return
end
for i, v in pairs(character:GetChildren()) do
if not v:IsA("BasePart") then
continue
end
task.spawn(fade, v)
end
end)
remoteEvent.OnServerEvent:Connect(function(Player)
local character = Player.Character
local humrp = character.HumanoidRootPart
local particle = rs:WaitForChild("Character"):WaitForChild("particle"):Clone()
particle.Parent = game.Workspace
particle.CFrame = humrp.CFrame
local runService = game:GetService("RunService")
runService.Heartbeat:Connect(function()
particle.Position = humrp.Position
end)
end)
local function lerp(p0,p1,t)
return p0*(1-t) + p1*t
end
local function quad(p0,p1,p2, t)
local l1 = lerp(p0,p1,t)
local l2 = lerp(p1,p2,t)
local quad = lerp(l1,l2,t)
return quad
end
remoteEvent.OnServerEvent:Connect(function(Player)
local character = Player.Character
local humrp = character.HumanoidRootPart
local start = game.Workspace:WaitForChild("Part").Position
local finish = game.Workspace:WaitForChild("Part2").Position
local middle = (finish - start) + Vector3.new(0,30,0)
for i = 1, 100 do
local t = i/100
local updated = quad(start,middle,finish,t)
humrp.Position = updated
wait(0.01)
end
end)
Thanks for helping me!