Hello, I want to make a system that only I will be able to have a character(Like owner only character).
I would like some examples, or tutorials. Thank you.
I can’t really provide examples or tutorials at the moment, but here is my solution:
- Create the custom character that you want and store it in ServerStorage.
- Use the Players.PlayerAdded event to detect when a player joins.
- Once a player joins, check if they are the owner (you). You can compare the players UserId to your UserId, and if they match, move on to the next step.
- Make the player’s character into the custom model you have using Player.Character = The custom model.
(Sorry if this was confusing)
You would also need to correct the camera position for the player as when you change the character it offsets the camera and changes the CameraSubject.
- Check if the player’s UserId matches the special-character-privileged user’s UserId.
- If the user’s UserId matches the UserId of the privileged list, assign a custom character to that user’s player.
For example (Script in ServerScriptService):
game.Players.ChildAdded.Connect(function(child)
if child:IsA("Player") then -- Detect if it's a new PLAYER that is added.
if child.UserId == userid then -- Replace "userid" with the whitelisted/privileged user's UserId.
-- Now, we respawn the player's character.
local newcharacter = referencetocharacterlmao -- Replace "referencetocharacterlmao" with your character model.
local oldcharactermodel = child.Character
local newcharactermodel = newcharacter:Clone()
local oldcharactermodelcframe = oldcharacter:GetPrimaryPartCFrame()
player.Character = newcharactermodel
newcharactermodel.Parent = game.Workspace
newcharactermodel:SetPrimaryPartCFrame(oldcharactermodelcframe)
oldcharactermodel:Destroy()
end
end
end)
Where do I put this exactly??
(Talking about the CharacterModel)
Put the script I wrote in ServerScriptService
.
You need to set custom characters primary part to its humanoidrootpart
Edit: and make sure the variable named “newcharacter” is set to your new custom character
I modified @ImagineAraknala’s script a little bit, but it still shows the error that I showed.
Also, the character is in ServerStorage.
Here is the modified script:
game.Players.ChildAdded:Connect(function(child)
if child:IsA("Player") then -- Detect if it's a new PLAYER that is added.
if child.UserId == 1890669972 then -- Replace "userid" with the whitelisted/privileged user's UserId.
-- Now, we respawn the player's character.
local newcharacter = game.ServerStorage.Dummy -- Replace "referencetocharacterlmao" with your character model.
local oldcharactermodel = child.Character
local newcharactermodel = newcharacter:Clone()
local oldcharactermodelcframe = oldcharacter:GetPrimaryPartCFrame()
player.Character = newcharactermodel
newcharactermodel.Parent = game.Workspace
newcharactermodel:SetPrimaryPartCFrame(oldcharactermodelcframe)
oldcharactermodel:Destroy()
end
end
end)
Make sure to set the character-model’s “Primary Part” to its HumanoidRootPart.
Yes, I checked that, and the character’s Primary Part is HumanoidRootPart. but the error is occurring.
Also, do I put the character model in the ServerStorage?
In the Explorer menu, simply drag and drop it into ServerStorage
I didn’t ask how to put the character model in the ServerStorage, I already know how to put the character in ServerStorage, I was asking if I put the character model in the ServerStorage, or in a different folder.
Oh right my bad I didn’t really read that properly, uh I would personally put it in ReplicatedStorage since it’ll be used multiple times