I am experiencing difficulties changing the player’s character to a different character model. Typically, to achieve this, you name the desired character rig “StarterCharacter” and parent it to the StarterPlayer folder in Studio. Then whenever a player respawns or a new player joins, they automatically spawn with the designated character model. However, my requirement is different: I want only the player who clicks a specific GUI button to reload with the new character model, while all other players in the server should retain their default characters regardless of respawns or reloads.
Here are the scripts I found –
Local script:
-- This Script is Parented to the GUI button
script.Parent.MouseButton1Click:Connect(function()
task.wait(3)
local plr = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local rig = game.Workspace.VP.OutfitPlace.FitFolder.Bunny
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = rig.HumanoidRootPart
game.ReplicatedStorage.ChangeCharacter:FireServer(plr)
end)
Server Script:
-- This Script is Parented to the ServerScriptService
local dontrepeat
local function onChangeCharacter(plr)
local char = plr.Character
local rig = game.Workspace.VP.OutfitPlace.FitFolder.Bunny
-- Check if rig's HumanoidRootPart already has "DontRepeat"
if not rig.HumanoidRootPart:FindFirstChild("DontRepeat") then
plr.Character = rig
end
wait()
if not rig.HumanoidRootPart:FindFirstChild("DontRepeat") then
dontrepeat = Instance.new("Attachment")
dontrepeat.Name = "DontRepeat"
dontrepeat.Parent = rig.HumanoidRootPart
wait()
char:Destroy()
end
end
game.ReplicatedStorage.ChangeCharacter.OnServerEvent:Connect(onChangeCharacter)
The intended functionality of these scripts is as follows: when a player clicks the GUI button, the local script communicates with the server script to identify the player who clicked the button. The server script then assigns the specified rig, called “Bunny”, to this player and destroys their previous character. However, when this transition occurs, I encounter several issues.
This is an example of what I want to happen after the Players character is changed:
-
The player moves well and correctly animates
-
The camera angle is correctly positioned so that if you zoom in you zoom into the character’s head
-
When the player zooms in the player’s Character and accessory fade out becoming transparent
-
When in shift lock or fully zoomed in the character will always face the way the player’s camera is facing
This is an example of what does happen after the player clicks the GUI and the players character is changed
-
The player does not move or animate correctly
-
The camera angle is not positioned correctly and when I zoom in it goes to the torso (It should be zooming into the head)
-
When zoomed in all the way the character and the accessories are still visible and obstruct the view
-
When in shift lock or fully zoomed in the character does not face the direction of the player’s camera
Requirements:
-
Exclusivity: Only players who click the GUI button should have the “Bunny” character. Additionally, these players should respawn with the “Bunny” character upon death or reload, while all other players should retain their default characters.
-
Functional Fixes: The “Bunny” character should be fixed so that it moves, animates, and zooms correctly, aligning with the desired behavior described above.
I would appreciate any assistance in resolving these issues