Cannot get simple idea to work

I don’t know what is wrong with this idea.

If you click Play in Studio and wait until Join shows up, it works fine.

After you reset; it will not work a second time.

The code never gets past the task.wait(4).

I don’t understand why.

SERVER:

local rs = game:GetService("ReplicatedStorage")
local event_Player_Loaded = rs:WaitForChild("PlayerLoaded")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		
		event_Player_Loaded:FireClient(player)

		print("PLAYER Loaded...")
		
		player.CharacterAppearanceLoaded:Connect(function(char)
		end)
		char.Humanoid.Died:Connect(function()
		end)
	end)
end)

CLIENT WELCOME:

local players = game:GetService("Players")
local player = players.LocalPlayer or players:GetPropertyChangedSignal("LocalPlayer"):wait()
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local ws = game:GetService("Workspace")
local camera = ws:WaitForChild("Camera")
local rs = game:GetService("ReplicatedStorage")
local event_Player_Loaded = rs:WaitForChild("PlayerLoaded")
local gui = script.Parent.Parent
local gui_Team = gui:WaitForChild("Team")
local gui_Welcome = script.Parent
local window = gui_Welcome:WaitForChild("Window")
local readout = window:WaitForChild("Readout")
local message = readout:WaitForChild("Message")

event_Player_Loaded.OnClientEvent:Connect(function()
	
	hrp.Anchored = true
	
	print("CAMERA Scriptable...")
	camera.CameraType = Enum.CameraType.Scriptable
	
	task.wait(4) -- the script will take about 4 seconds
	
	print("Show Team Gui")
	gui_Welcome.Enabled = false
	gui_Team.Enabled = true

end)

CLIENT TEAM:

local players = game:GetService("Players")
local player = players.LocalPlayer or players:GetPropertyChangedSignal("LocalPlayer"):wait()
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local ws = game:GetService("Workspace")
local camera = ws:WaitForChild("Camera")
local gui = script.Parent
local window = gui:WaitForChild("Window")
local choose = window:WaitForChild("Choose")
local join =  choose:WaitForChild("Join")



join.Activated:Connect(function()
	
	gui.Enabled = false
	hrp.Anchored = false

	print("CAMERA Custom...")
	camera.CameraType = Enum.CameraType.Custom
	
end)

Here is the file:

Startup.rbxl (65.0 KB)

I need this to work and have spent hours trying to figure it out. Any help appreciated.

Found the line that was breaking it.

camera.CameraType = Enum.CameraType.Scriptable

Changed to:

if camera.CameraType ~= Enum.CameraType.Scriptable then
print(“CAMERA Scriptable…”)
camera.CameraType = Enum.CameraType.Scriptable
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.