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

I assign g as the key but when i press other buttons the code still run help?

Asked by
Damo999 182
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

it might be a stupid error but every time i press a key my camera changes the problem is that i assigned g as the key and for some reason any button i press it runs the code and i'm not sure why here is the code.

buttonPressed = false
mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyDown:connect(function(key)
    buttonPressed = true 
    if key == "g" then
        end
end)

    mouse.KeyUp:connect(function(key)
    buttonPressed = false
    if key == "g" then
    end
    while wait() do
    if buttonPressed then
        local target = workspace.Part
        local camera = workspace.CurrentCamera
        camera.CameraType = Enum.CameraType.Scriptable
        camera.CameraSubject = target

        camera.CoordinateFrame = CFrame.new(target.Position)
        *CFrame.new(2.9,4.6,-22)
        *CFrame.Angles(0,-3.1,0)
    else
        game.Workspace.CurrentCamera.CameraSubject =    game.Players.LocalPlayer.Character.Humanoid
        game.Workspace.CurrentCamera.CameraType = "Custom"
end
    end
    end)




1 answer

Log in to vote
1
Answered by 9 years ago

I see your problem. At lines 12-13, you have the function and then you immediately end it with an end. You should move that end to around line 28.

Ad

Answer this question