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

How to make a 2D-3D script? [closed]

Asked by 10 years ago

Like you start off at 2D and then you're going to another area and turns 3D view

Closed as Not Constructive by Articulating and evaera

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 10 years ago

Ok listen Carefully!

Step 1: Put 2 Bricks

Step 2: 2D, Place this script one of your bricks

local ting = 0

function GetMass(object)
    local mass = 0
    if pcall(function() return object:GetMass() end) then
        mass = object:GetMass()
    end
    for _,child in pairs(object:GetChildren()) do
        mass = mass + GetMass(child)
    end
    return mass
end


function onTouch(part) 
local human = part.Parent:findFirstChild("Humanoid") 
if (human == nil) then return end
    if ting == 0 and human.Parent:findFirstChild("LocalScript") == nil then
        ting = 1
        script.Parent.Reflectance = 0.1

local d = script.LocalScript:clone()
d.Parent = human.Parent

    wait()
    local torso = human.Parent.Torso 
    local bp = Instance.new("BodyPosition")
    bp.Name = "TwoD"
    bp.position = torso.Position
    bp.P = 1000000
    bp.D = 1000
    bp.maxForce = Vector3.new(0, 0, 1000000)
    bp.Parent = torso
    local bf = Instance.new("BodyForce")
    bf.force = Vector3.new(0, 100*GetMass(human.Parent), 0)
    bf.Parent = torso
    human.Parent.Humanoid.WalkSpeed = 24
    human.Parent.DescendantAdded:connect(function()
        bf.force = Vector3.new(0, 100*GetMass(human.Parent), 0)
    end)
    human.Parent.DescendantRemoving:connect(function()
        bf.force = Vector3.new(0, 100*GetMass(human.Parent), 0)
    end)


        wait(2)
        ting = 0
        script.Parent.Reflectance = 0
end
end 
script.Parent.Touched:connect(onTouch)

in the SAME brick, create a new localscript (advanced Objects -> localscript) and copy this to local script

lockCamera = false
    distance = 30
    height = 5

local torso = script.Parent.Torso
local center = Instance.new("Part")
center.Name = script.Parent.Name .. " Center"
center.Transparency = 1
center.CanCollide = false
center.Size = Vector3.new(1,1,1)
center.CFrame = CFrame.new(Vector3.new(0,0,0),Vector3.new(0,0,-1))
center.Position = torso.Position
center.Parent = game.Workspace
local bp = Instance.new("BodyPosition")
bp.position = center.Position
bp.maxForce = Vector3.new(1000000, 1000000, 1000000)
bp.Parent = center
local bg = Instance.new("BodyGyro")
bg.maxTorque = Vector3.new(9e+005, 9e+005, 9e+005)
bg.cframe = center.CFrame
bg.Parent = center
local cam = game.Workspace.CurrentCamera
cam.CameraSubject = center
cam.CameraType = Enum.CameraType.Attach


while torso.Parent do
    wait()
    center.BodyPosition.position = torso.Position
    if lockCamera then
        cam.CoordinateFrame = CFrame.new(Vector3.new(center.Position.x + distance,center.Position.y + height,center.Position.z))
    end
    if torso.Parent.Humanoid.Health < 1 then
        torso.TwoD:remove()
        torso.BodyForce:remove()
    end
end

center:Remove()

Step 3: changing 3D

Ok now go to your second brick, create a script and copy this

local ting = 0

function onTouch(part) 
    local human = part.Parent:findFirstChild("Humanoid") 
    if (human == nil) then return end
    if ting == 0 and human.Parent.LocalScript ~= nil then
        ting = 1
        script.Parent.Reflectance = 0.1
        local charitem = human.Parent:GetChildren()
        for i = 1, #charitem do
            if charitem[i].Name == "LocalScript" then
                charitem[i]:remove()
            end
        end
        local torsoitem = human.Parent.Torso:GetChildren()
        for i = 1, #torsoitem do
            if torsoitem[i].Name == "TwoD" or torsoitem[i].Name == "BodyForce" then
                torsoitem[i]:remove()
            end
        end
        game.Workspace.CurrentCamera:remove()
        local cam = script.Instance:clone()
        cam.CameraSubject = human
        cam.Parent = game.Workspace
        game.Workspace.CurrentCamera = cam
        wait(2)
        ting = 0
        script.Parent.Reflectance = 0
    end
end 
script.Parent.Touched:connect(onTouch)

Now at advanced objects, create a camera and rename to Instance, put the camera to 3D Script

Step 4: Test it, Got problems? reply

Ad