I have a spawn script that moves the character to a spawn block, and it moves the character but not the camera, here’s the code (client side)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local button_one = script.Parent:FindFirstChild("SpawnLocationOne")
local button_two = script.Parent:FindFirstChild("SpawnLocationTwo")
local cam = game.Workspace.Camera
local spawns
local rootPart = char:WaitForChild("HumanoidRootPart")
button_one.MouseButton1Click:Connect(function()
script.Parent.Parent.Enabled = false
spawns = game.Workspace.Spawns
local randomItem = spawns.SpawnPart
rootPart.CFrame = randomItem.CFrame
wait(.5)
spawns = nil
end)
BJCarpenter
(BJCarpenter)
#2
I have no idea, but why do you get the Camera and then not use it? And why isn’t it:
Workspace.CurrentCamera
And I have a question. If you move the character localy does that move it on the server?
Do you have any other code in your game? The code you provided should work.
The only problem I can think of is that character replication thing, see if it works when you add a task.wait()
before starting your connection.
Forummer
(Forummer)
#4
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local rootPart = char:WaitForChild("HumanoidRootPart")
local screenGui = script:FindFirstAncestorWhichIsA("ScreenGui")
local frame = script.Parent
local button_one = frame:FindFirstChild("SpawnLocationOne")
local button_two = frame:FindFirstChild("SpawnLocationTwo")
local cam = workspace.CurrentCamera
local spawns = workspace:WaitForChild("Spawns")
button_one.MouseButton1Click:Connect(function()
screenGui.Enabled = false
local randomSpawn = spawns:GetChildren()[math.random(1, #spawns:GetChildren())]
rootPart.CFrame = randomSpawn.CFrame
cam.CameraSubject = randomSpawn
task.wait(0.5)
cam.CameraSubject = rootPart
end)
Is this what you were trying to achieve?