Heyo! Trying to change the camera position through a remote event from a client script to a server script, but it isn’t working. I’ve done tests to confirm that the events are getting fired (prints), and they are indeed getting fired, but the camera type just isnt changing.
Both RemoteEvents are inside of ReplicatedStorage
Here’s the server code:
local camera = workspace.CurrentCamera
local camPart = workspace.MenuCamera
local CameraPosEvent = game.ReplicatedStorage.CameraPos
local CameraReset = game.ReplicatedStorage.CameraReset
CameraPosEvent.OnServerEvent:Connect(function()
print("god this code is painful but works")
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = camPart.CFrame
end)
CameraReset.OnServerEvent:Connect(function()
print("NO")
camera.CameraType = Enum.CameraType.Custom
end)
Below we have the client code:
-- Variables
local player = game.Players.LocalPlayer
local playerGUI = player.PlayerGui
local MainGUI = playerGUI.MenuScreen
local PlayModule = MainGUI.PlayModule
local TweenService = game:GetService("TweenService")
local TeleportationPad = workspace.TeleportationPad
local Event = game.ReplicatedStorage.CameraPos
local Event2 = game.ReplicatedStorage.CameraReset
-- PlayModule
PlayModule.Visible = true
PlayModule.MouseEnter:Connect(function()
TweenService:Create(PlayModule.UIStroke, TweenInfo.new(0.3), {Thickness = 4}):Play()
end)
PlayModule.MouseLeave:Connect(function()
TweenService:Create(PlayModule.UIStroke, TweenInfo.new(0.3), {Thickness = 1}):Play()
end)
PlayModule.PlayButton.MouseButton1Click:Connect(function()
TweenService:Create(MainGUI.Transition, TweenInfo.new(0.5), {BackgroundTransparency = 0}):Play()
wait(0.5)
Event2:FireServer()
player.Character:WaitForChild("HumanoidRootPart").CFrame= TeleportationPad.CFrame + Vector3.new(0, 3, 0)
PlayModule.Visible = false
wait(2)
TweenService:Create(MainGUI.Transition, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
end)
-- Other
Event:FireServer()
Don’t worry, at least you tried some solutions before going to the devforum. If I was in your perspective I wouldn’t have known you have to add a wait either, I only know because I’ve experienced the same problem as you before.