I’m making a menu screen when you enter the game, but when the player clicks the playbutton and I set the CameraType to custom, it doesn’t work, here a video of what I mean.
robloxapp-20201017-1241059.wmv (763.2 KB)
The character stands on the baseplate, but the camera is somewhere else. I use a localscript and a serverscript. This is the local script.
-- Services
local Players = game:GetService("Players")
local tweenService = game:GetService("TweenService")
local screenGui = script.Parent
local playButton = screenGui.PlayButton
local blackScreen = screenGui.BlackScreen
local camera = workspace.CurrentCamera
local player = Players.LocalPlayer
local remoteEvent = game.ReplicatedStorage.remoteEvents.mainmenuEvent
local Info = TweenInfo.new(
2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
blackScreen.Visible = true
remoteEvent.OnClientEvent:Connect(function(playing)
print("yeah")
if playing then
wait()
if camera.CameraType ~= Enum.CameraType.Scriptable then
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = workspace.lookpart.CFrame
end
print("seeing playbutton")
playButton.Visible = true
blackScreen.BackgroundTransparency = 1
playButton.MouseButton1Click:Connect(function()
blackScreen.Visible = true
blackScreen.BackgroundTransparency = 1
local tween = tweenService:Create(blackScreen, Info, {BackgroundTransparency = 0})
tween:Play()
tween.Completed:Wait()
remoteEvent:FireServer()
end)
else
print("tweening")
blackScreen.BackgroundTransparency = 0
blackScreen.Visible = true
local tween = tweenService:Create(blackScreen, Info, {BackgroundTransparency = 1})
tween:Play()
camera.CameraType = Enum.CameraType.Custom
tween.Completed:Wait()
blackScreen.Visible = false
playButton.Visible = false
end
end)
here is the serverscript
-- Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage.remoteEvents.mainmenuEvent
local camera = workspace.CurrentCamera
Players.PlayerAdded:Connect(function(player)
player.RespawnLocation = workspace.SpawnLocation
player.CharacterAdded:Connect(function()
print("character added")
end)
wait()
remoteEvent:FireClient(player, true)
end)
remoteEvent.OnServerEvent:Connect(function(player)
player.RespawnLocation = workspace.realspawn
player:LoadCharacter()
print("loaded character")
remoteEvent:FireClient(player, false)
end)
I would be happy if someone could help me with this.