Alright, I don’t know what I’ve done wrong, even the output doesn’t say anything! I’ve been trying to make a Menu with clickable objects. What I am doing is placing a ClickDetector in a 3DText, and putting a LocalScript inside the detector. The LocalScript should smoothly move the Camera to the other located part (PlayCam) when the Part (3DText) is clicked, but it doesn’t. The camera doesn’t move and the output doesn’t give any error. Before responding please consider that I am a noob to scripting.
The Script:
local click = script.Parent
local CurrentCamera = workspace.CurrentCamera
local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local function CameraSlideLeft()
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local TI = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,1)
local Goal = {CFrame = Workspace.PlayCam.CFrame}
local Animation = TweenService:Create{CurrentCamera, TI, Goal}
Animation:play()
end
click.MouseClick:Connect(CameraSlideLeft)
I got it to work with a remote event. By the way, LocalScripts don’t work in Workspace (I think).
First:
Make a RemoteEvent and place in in ReplicatedStorage, for me the name is “RemoteEvent” but you can replace it with whatever you want.
Second:
The script (make it a normal script) inside the ClickDetector make it:
--This is the script inside of ClickDetector
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent") --The name you chose for the RemoteEvent
local Workspace = game:GetService("Workspace")
script.Parent.MouseClick:Connect(function(plr)
remoteEvent:FireClient(plr)
end)
Third:
Add a LocalScript in StarterGui and make it this:
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent") --The name you chose for the RemoteEvent
local Workspace = game:GetService("Workspace")
local CurrentCamera = workspace.CurrentCamera
local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
remoteEvent.OnClientEvent:Connect(function(plr)
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local TI = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,1)
local Goal = {CFrame = Workspace.PlayCam.CFrame}
local Animation = TweenService:Create(CurrentCamera, TI,Goal)
Animation:play()
end)
Umm, may ask one more question? I want to make a camera transition back to the avatar’s actual camera, I’ve tried some things, but it doesn’t work. Here is the script I currently have, I am trying with the same method but with some changes:
local RemoteEvent = game.ReplicatedStorage:WaitForChild("PlayCam-Player")
local Workspace = game:GetService(“Workspace”)
local CurrentCamera = workspace.CurrentCamera
local TweenService = game:GetService(“TweenService”)
local Player = game.Players.LocalPlayer
RemoteEvent.OnClientEvent:Connect(function(plr)
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local TI = TweenInfo.new(4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,0)
local Goal = {CurrentCamera = Player.CameraMinZoomDistance}
local Animation = TweenService:Create(CurrentCamera, TI,Goal)
Animation:play()
Hey, you probably already know this but, maybe try copying the avatar’s original camera position.
For example, on the local script put this
local remoteEvent = game.ReplicatedStorage:WaitForChild(“RemoteEvent”) --The name you chose for the RemoteEvent
local CurrentCamera = workspace.CurrentCamera
local TweenService = game:GetService(“TweenService”)
local player = game.Players.LocalPlayer
local Workspace = workspace
repeat wait() until player – Wait for player
local originalCameraPosition = CurrentCamera.CFrame
remoteEvent.OnClientEvent:Connect(function(plr)
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local TI = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,1)
local Goal = {CFrame = Workspace.PlayCam.CFrame}
local Animation = TweenService:Create(CurrentCamera, TI,Goal)
local ReturnToCamera = TweenService:Create(CurrentCamera, TI,originalCameraPosition)
Animation:play()
end)