So I am Trying to make a Script where The CameraPart Goes to a different position like for example I click a play button and the camera moves to a set position
The script I made I tried adding a MouseButton1Click and Keycode so if the player would be either on console or PC they would have to click a Button/Key on their keyboard/controller it would move the camera as well as change the menu I have but it will not work I have tried looking through the devforum, YouTube, etc.
here is the script i have
local userinputService = game:GetService('UserInputService')
local CurrentCamera = workspace.CurrentCamera
local Finish = workspace.CameraPart2
local Start = workspace.CameraPart
local Play = script.Parent
Play.MouseButton1Click:Connect(function()
Start.Position = Finish.Position
end)
userinputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.ButtonA then -- Where it says ButtonA is how to change the Keycode
Start.Position = Finish.Position
end
end)
userinputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.Space then -- Where it says ButtonA is how to change the Keycode
Start.Position = Finish.Position
end
end)
Well, what are the two CameraParts? From what I can tell, you’re just changing the position of the Start camera part to the position of the Finish camera part, but you’re not actually changing the position of the actual player camera, unless you have another script that changes the player camera to the positions of the CameraParts.
CurrentCamera.CameraType = Enum.CameraType.Scriptable
Play.MouseButton1Click:Connect(function()
CurrentCamera.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
end)
userinputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Space then -- Where it says ButtonA is how to change the Keycode
CurrentCamera.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
end
end)
Dude im sorry that you have to go through this but heres the entire script
local userinputService = game:GetService('UserInputService')
local CurrentCamera = workspace.CurrentCamera
local Finish = workspace.CameraPart2
local Start = workspace.CameraPart
local Play = script.Parent
CurrentCamera.CameraType = Enum.CameraType.Scriptable
Play.MouseButton1Click:Connect(function()
Finish.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
end)
userinputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.ButtonA then -- Where it says ButtonA is how to change the Keycode
Finish.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
end
end)
userinputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.Space then -- Where it says ButtonA is how to change the Keycode
Finish.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
end
end)
so setting up those lines of code to where i located will work?
userinputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.Space then -- Where it says ButtonA is how to change the Keycode
CurrentCamera.CFrame = Start.CFrame
CurrentCamera.CFrame = Finish.CFrame
end
end)