Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script won't rotate bricks? PLEASE READ URGENT

Asked by 9 years ago

So i'm making a bezier curve script, and I have the rotation set up, and it looks fine, no errors, but the bricks don't rotate! It works for Position, and I don't know why it isn't working for Rotation. Any help? Here is the script:

bc={}
rbc={}
p1={game.Workspace.Start1.Position,game.Workspace.Cont1.Position,game.Workspace.Start2.Position}
p2={game.Workspace.Start2.Position,game.Workspace.Cont2.Position,game.Workspace.EndStart.Position}
r1={game.Workspace.Start1.Rotation,game.Workspace.Cont1.Rotation,game.Workspace.Start2.Rotation}
r2={game.Workspace.Start2.Rotation,game.Workspace.Cont2.Rotation,game.Workspace.EndStart.Rotation}
function CreateLerpsP1()
    for i=1,10 do 
        local t = i/10
        bc[i] = p1[1]*(1-t)^2+2*p1[2]*(1-t)*t+p1[3]*t^2
    end
    for i=1,10 do 
        local t = i/10
        rbc[i] = r1[1]*(1-t)^2+2*r1[2]*(1-t)*t+r1[3]*t^2
    end
    for i=1,10 do
        local t=Instance.new("Part",workspace.CurTrack)
        t.Name="TrackPoint"
        t.BrickColor=BrickColor.Blue()
        t.Anchored=true
        t.CanCollide=false
        t.Size=Vector3.new(4,1,2)
        t.TopSurface=Enum.SurfaceType.Smooth
        t.BottomSurface=Enum.SurfaceType.Smooth
        if i~=1 then
        t.CFrame=CFrame.new(bc[i]:Lerp(bc[i-1],0.5),bc[i])
        t.Rotation=Vector3.new(rbc[i]:Lerp(rbc[i-1],0.5),rbc[i])
        else
        t.CFrame=CFrame.new(bc[i]:Lerp(p1[1],0.5),bc[i])
        t.Rotation=Vector3.new(rbc[i]:Lerp(r1[1],0.5),rbc[i])
        end
    end
end

function CreateLerpsP2()
    for i=1,10 do 
        local t = i/10
        bc[i] = p2[1]*(1-t)^2+2*p2[2]*(1-t)*t+p2[3]*t^2
    end
    for i=1,10 do 
        local t = i/10
        rbc[i] = r2[1]*(1-t)^2+2*r2[2]*(1-t)*t+r2[3]*t^2
    end
    for i=1,10 do
        local t=Instance.new("Part",workspace.CurTrack)
        t.Name="TrackPoint"
        t.BrickColor=BrickColor.Blue()
        t.Anchored=true
        t.CanCollide=false
        t.Size=Vector3.new(4,1,2)
        t.TopSurface=Enum.SurfaceType.Smooth
        t.BottomSurface=Enum.SurfaceType.Smooth
        if i~=1 then
        t.CFrame=CFrame.new(bc[i]:Lerp(bc[i-1],0.5),bc[i])
        t.Rotation=Vector3.new(rbc[i]:Lerp(rbc[i-1],0.5),rbc[i])
        else
        t.CFrame=CFrame.new(bc[i]:Lerp(p2[1],0.5),bc[i])
        t.Rotation=Vector3.new(rbc[i]:Lerp(r2[1],0.5),rbc[i])
        end
    end
end
CreateLerpsP1()
CreateLerpsP2()
game.Workspace.Start1.Changed:connect(function() game.Workspace.CurTrack:ClearAllChildren() CreateLerpsP1() CreateLerpsP2() end)
game.Workspace.Cont1.Changed:connect(function() game.Workspace.CurTrack:ClearAllChildren() CreateLerpsP1() CreateLerpsP2() end)
game.Workspace.Start2.Changed:connect(function() game.Workspace.CurTrack:ClearAllChildren() CreateLerpsP1() CreateLerpsP2() end)
game.Workspace.Cont2.Changed:connect(function() game.Workspace.CurTrack:ClearAllChildren() CreateLerpsP2() CreateLerpsP1() end)
game.Workspace.EndStart.Changed:connect(function() game.Workspace.CurTrack:ClearAllChildren() CreateLerpsP2() CreateLerpsP1() end)

1 answer

Log in to vote
0
Answered by 9 years ago

So let's say that the variables cf and rotrepresent the CFrame/rotation you're trying to set.

try doing this:

t.CFrame=CFrame.new(cf.p,rot) --using .p changes the CFrame to a Vector3

EDIT: I mean something like this

if i~=1 then
t.CFrame=CFrame.new(bc[i]:Lerp(bc[i-1],0.5),bc[i],Vector3.new(rbc[i]:Lerp(rbc[i-1],0.5),rbc[i]))
else
t.CFrame=CFrame.new(bc[i]:Lerp(p1[1],0.5),bc[i],Vector3.new(rbc[i]:Lerp(r1[1],0.5),rbc[i]))
end

Basically you're just tacking on the Rotation lines to the end of the CFrame lines.

0
Could you try being more specific to my script? I've never done anything like what you said before, maybe then i'll understand more. TealTeam 40 — 9y
0
Check my edit. TheGuyWithAShortName 673 — 9y
0
For some reason, that just made all of the bricks go to the same spot. TealTeam 40 — 9y
0
And they still don't rotate, either. Is what im trying to do impossible to code or am I just missing something? TealTeam 40 — 9y
0
Please respond, I am really starting to get pressed for time with this TealTeam 40 — 9y
Ad

Answer this question