so I'm trying to make a game where if you click a button your character would change, problem is when i set the player.Character to a new model that has just been added to the workspace, i try to change the camera.Subject to the humanoid inside the new model, but it doesn't seem to work.

it doesnt seem to display any errors either, is Lua broken? or am i trippin?

PS : the cameras cameratype is INDEED set to Custom, still doesn't work though.

here is the whole script

the local script :

local userinputservice = game:GetService("UserInputService")
--////////////////////////////////////////////////////////

local player = game.Players.LocalPlayer
	--///////////////////         ///////////   ///////
--///////////////////   /////////////// /////////
local rp = game:GetService("ReplicatedStorage")

local shifting_event = rp.Events:FindFirstChild("Shifting")


	--//////////////////////////////////// /
	--//////////////// /////////////    ///////////////
	





local inbetween_delay = 0.1

local transformkeyF = Enum.KeyCode.F
local transformkeyQ = Enum.KeyCode.Q
local transformkeyP = Enum.KeyCode.P


local Total_Titan_shifting_Forms = 3

local shifting_types = {}


local Titan_1  = {'Collosal',transformkeyF}

table.insert(shifting_types,Titan_1)

local Titan_2 = {'Female Titan',transformkeyQ}

table.insert(shifting_types,Titan_2)

local Titan_3 = {'Attack Titan',transformkeyP}

table.insert(shifting_types,Titan_3)

userinputservice.InputBegan:Connect(function(input)
	
	if input.KeyCode == transformkeyP then
		for i,v in pairs(shifting_types) do
			if v[2] == transformkeyP then
				
				 local SF = v[1]
				shifting_event:FireServer(SF)
				
	    
				
				print (string.format("%q Shifting",v[1]))
				wait(inbetween_delay)
			end
		end
	end
end)
userinputservice.InputBegan:Connect(function(input)
  			 if input.KeyCode == transformkeyQ then
					for i,v in pairs(shifting_types) do
			if v[2] == transformkeyQ then
				
				local SF = v[1]
				shifting_event:FireServer(SF)
		
				wait(4)
			
			
	game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
				game.Workspace.CurrentCamera.CameraSubject = game.Player.LocalPlayer.Character.Humanoid

				game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Follow

			
							print (string.format("%q Shifting",v[1]))
						wait(inbetween_delay)
			end
		end
	end
end)

					
					
					
					
userinputservice.InputBegan:Connect(function(input)
						 if input.KeyCode == transformkeyF then
								for i,v in pairs(shifting_types) do
			if v[2] == transformkeyF then
				
				local SF = v[1]
				shifting_event:FireServer(SF)
				
										print (string.format("%q Shifting",v[1]))
										  wait(inbetween_delay)
									end
								end
							end
						end)
	
		
	

serverside script :

local rp = game:GetService("ReplicatedStorage")

local shifting_event = rp.Events:FindFirstChild("Shifting")

local ss = game:GetService("ServerStorage")

local TitanModels = {} 
	
	
local Collosal_Titan = {form = "Collosal",model = ss:FindFirstChild("Collosal")}	
	
table.insert(TitanModels,Collosal_Titan)
	
	
	
	
	

shifting_event.OnServerEvent:Connect(function(player,SF)
	
	if SF == 'Collosal' then 
		Collosal_Titan.model.Parent = workspace
		
		player.Character = Collosal_Titan.model 
		
		

			
		
		  
	end
	
end)

1 comment

0

Maybe try adding findfirstchild