I’m trying to make a character selector, but the camera isn’t following the character
local:
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)
server
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
local clone = game.Workspace.Rig:Clone()
clone.Name = player.Name
clone.Parent = workspace
clone.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame
player.Character:Destroy()
player.Character = clone
end)
4 Likes
Make the characters, then set the current camera mode to Scriptable, then set the CFrame of the camera to the new character.
~ Sincerely, Ihaveash0rtname
“Happy Scripting!”
2 Likes
Is there any function that can check if the player’s character was made, also would this method follow the character
asherppan
(concat_nate)
July 15, 2023, 10:29pm
#4
local:
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(workspace.CurrentCamera)
end)
server
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, camera)
local clone = game.Workspace.Rig:Clone()
clone.Name = player.Name
clone.Parent = workspace
clone.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame
player.Character:Destroy()
player.Character = clone
camera.CameraType = Enum.CameraType.Scriptable;
camera.CFrame = clone.HumanoidRootPart.CFrame;
camera.CameraType = Enum.CameraType.Custom;
end)
2 Likes
i’m getting this error “attempt to index nil with ‘CameraType’”
asherppan
(concat_nate)
July 15, 2023, 10:43pm
#6
When you say it doesn’t move with the character, is it unmovable or positioned at an incorrect angle?
the camera is unmovable and doesn’t move with the character although you can rotate it
asherppan
(concat_nate)
July 15, 2023, 10:51pm
#8
Try
workspace.CurrentCamera.CameraSubject = [the new model humanoid rootpart]
In the localscript
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(workspace.CurrentCamera)
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
end)
didnt work
asherppan
(concat_nate)
July 15, 2023, 10:59pm
#10
The subject must be the new model, not the current.
You could try
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
LocalPlayer.CharacterAdded:Connect(function(char)
workspace.CurrentCamera.CameraSubject = char.HumanoidRootPart
end);
But it would be better for you to access the new character directly, consider possibly modulizing this as firing another remote event to the client giving it character information would probably work, but seems excessive.
1 Like
Tried the second option and it worked!
Code for anyone who has the same problem:
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(workspace.CurrentCamera)
end)
game.ReplicatedStorage.RemoteFunction.OnClientInvoke = function(player)
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, camera)
local clone = game.Workspace.Rig:Clone()
clone.Name = player.Name
clone.Parent = workspace
clone.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame
player.Character:Destroy()
player.Character = clone
game.ReplicatedStorage.RemoteFunction:InvokeClient(player)
end)
1 Like
system
(system)
Closed
July 29, 2023, 11:23pm
#12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.