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

can somone please help me fix a script for my game? thank you

Asked by
orord 0
8 years ago
Edited 8 years ago

so my scripts are suppose to disable the controls which it does then switch the camera and only allow D and D to be pressed

the parts or scripts i have in my workspace:

CameraLineEnd <part CameraLinePos<part CameraLineStart<part LocalPlayerCameraPart<Part

that is suppose to allow the player camera to not go past the end and start pos

scripts:

playerenters main CameraControls CameraManipulation

CameraControls :

repeat

wait (.1)
until game.Workspace.LocalPlayerCameraPart
local camobj = game.Workspace.LocalPlayerCameraPart

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.D then
    print("D was presssed")
    camobj.MovmentValue.Value = "Right"
    elseif inputObject.Keycode == Enum.Keycode.A then
    print ("A was pressed")
    camobj.Movementvalue.Value = "Left"
    end 
end
function onKeyLet (inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.Keycode.D then 
        print ("D was let")
        camobj.MovementValue.Value = "none"
    elseif inputObject.keycode == Enum.KeyCode.A then
        print ("A was let")
        camobj.MoveMentValue.Value = "none"
    end

end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyLet)

CameraManipulation :

 local camera = game.Workspace.CurrentCamera
local bool = false

while true do 
    wait()
    camera.CameraType = "Follow"
    if bool == false then
        bool = true
        part = Instance.new ("Part")
        part.Name = "LocalPlayerCameraPart"
        part.Anchored = true
        part.CanCollide = false 
        part.Size = Vector3.new(1,1,1)
        part.CFrame = CFrame.new(game.Workspace.CameraLineStart.Position)
        part.Transparency = 1
        part.Parent = game.Workspace
        part2 = Instance.new("Part")
part2.Name = "localPlayerCameraPos"
part2.Anchored = true
part2.CanCollide = false
part2.Size = Vector3.new(1,1,1)
part2.CFrame =CFrame.new(game.Workspace.CameraLinePos.Position)
part2.Transparency = 1
part2.Parent = game.Workspace
local val = Instance.new ("StringValue")
    val.Parent = part
    val.Name = "MovementValue"
    val.Value = "none"
    local cammove = game.Workspace.CameraMovement:Clone()
    cammove.Parent = game.Players.LocalPlayer.PlayerGui
    cammove.Disabled = false
end
camera.CameraSubject = part
camera.CoordniateFrame = part2.CFrame
camera.FieldOfView = 50


    end

local cam = game.Workspace.LocalPlayerCameraPart
local pos = game.Workspace.LocalPlayerCameraPos
local val = cam.MovementValue
local i = 1 

while true do 
    wait()
    local mag1 = (cam.Position - game.Workspace.CameraLineStart.Position).magnitude
    local mag2 = (cam.Position - game.Worksapce.CameraLineEnd.Position) .magnitude
    if val.Value == "left" then
        i = i + 1 
        if i < 50 then
            cam.CFrame = cam.CFrame - Vector3.new(0,0,(.02*i+.5)
            )pos.CFrame = pos.CFrame - Vector3.new(0,0,(.02*i+.5)
)       else
            cam.CFrame = cam.CFrame - Vector3.new(0,0,1.5)
            pos.CFrame = pos.CFrame - Vector3.new(0,0,1.5)
        end
            end
        if val.Value == "right" then 
            if mag2 > 0 then i = i + 1
                print (i)
                if i < 50 then 
                    print ("first")
                    cam.CFrame = Vector3.new (0,0,(.02*i)+.5)
                    pos.CFrame = Vector3.new (0,0,(.02*i)+.5)

                   else 
                    print("second")
                    cam.CFrame = cam.CFrame + Vector3.new(0,0,1.5)
                    pos.CFrame = pos.CFrame + Vector3.new(0,0,1.5)

                end
            end
         elseif val.Value == "none" then i = 1

            end 
        end

        camera.CameraSubject = part
        camera.CoordinateFrame = part2.CFrame
        camera.FieldOfView = 50

even though if nobody can help me with this i would love to thank everyone for atleast trying and looking at my thread :)

0
Can you figure out more specifically what doesn't work so we don't have to debug about 120 lines of code? Maybe isolate the problem to about 10? GoldenPhysics 474 — 8y
0
well i know what doesnt work the camera and cameracontrols do work or dont activate so you can scratch main and players orord 0 — 8y
0
im new to scripting its like the scripts dont activate at all orord 0 — 8y
0
could i invite you to a mulitplayer studio to show what parts actually function orord 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Please put the whole code in code block, thank you.

0
sorry about that orord 0 — 8y
Ad

Answer this question