Hi! I’ll get straight to the point I’m making a rail grinding system but I’ve been put at a sort of standstill for a while since I encountered 2 problems.
The first is figuring out where a player lands on a rail, on paper it seems simple, simply do it between two points in a 3D space, the problem is I do not know what I should do to achieve that.
The second is actually moving the player between these two points, now I know how to detect where they’re going to be moving using :Dot but other than that, I’m completely stuck as to how to make it seem like they’re actually stuck on the rail.
As always, if anyone can help me trying to figure these issues out, even a small pointer in the right direction I’d greatly appreciate it!
Oh right, and before I forget here’s the code segment I’m using for this!
while true do
Wait(0.1)
for i,v in pairs(game.Workspace:GetDescendants()) do
if v:FindFirstChild("RailChecked") and not v:FindFirstChild("RailCCheck") then
local part = v.RailChecked.Value
part.Touched:Connect(function()
if railgrinding == false then
railgrinding = true
local targpoint
print("let's grind!")
grindpart = part
local vel1 = CFrame.new(v.Attachment0.WorldPosition,v.Attachment1.WorldPosition).LookVector:Dot(player.Character.HumanoidRootPart.Velocity.Unit)
if vel1 < 0 then
print("We going forwards!")
targpoint = v.Attachment1.WorldPosition
end
if vel1 > 0 then
print("Rewind time")
targpoint = v.Attachment0.WorldPosition
end
end
end)
local tag = Instance.new("Folder")
tag.Name = "RailCCheck"
tag.Parent = v
table.insert(rails,1,v)
end
end
end