Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't this script work where I can only allow certain users to have a script run?

Alright, so I'm a modeler thats just trying to put together a script that makes it so only certain people can have a model as their starter character but its not working and I dont know why, any help?

local players = {"Voxoc"}

game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:connect(function(chr) for i = 1, #players do if players[i] == plr.Name then local object = game.Workspace["Armored Titan"]

local clonedObject = object:Clone() clonedObject.Name = "StarterCharacter" clonedObject.Parent = game.StarterPlayer end end end) end)

1 comment

0

Please use lua code blocks when inserting your code to a question.

1 answer

--[[

The following script has been tested in a case with more than one player and different names
This is a Server script (regular script) inside ServerScriptService
You can rename the players and the model at will
The StarterCharacter you want to have is placed in a folder inside of ServerStorage (More in the script)
The character has to be unanchored, I didn't manage to make it unanchorable by script
!! The model of the starter Character needs a PrimaryPart to be set !!

--]]

local CharacterModel = game.ServerStorage:FindFirstChild("StarterCharacters").EEEsus
local PlayersToTransform = {"bostaffmanbulgaria1", "Player1", "Player2"}


game.Players.PlayerAdded:Connect(function(player)
for i,v in pairs(PlayersToTransform) do

if game.Players:FindFirstChild(v) then
if not game.StarterPlayer:FindFirstChild("StarterCharacter") then


local NewStarterCharacter = CharacterModel:Clone()
NewStarterCharacter.PrimaryPart = NewStarterCharacter:FindFirstChild("HumanoidRootPart")
NewStarterCharacter.Name = "StarterCharacter"
NewStarterCharacter.Parent = game.StarterPlayer


end
end
end
end)

2 comments

0

Alright, so everytime I run it it says primary part is not a valid member of part

0

Doesn't it say "Not a valid member of Model" instead? There's a thing called PrimaryPart in the Model itself. Set it to HumanoidRootPart (Inside your model character)

This discussion is preserved as it was. New answers, comments, and votes are closed.