Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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)

0
Please use lua code blocks when inserting your code to a question. Torren_Mr 334 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
--[[

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)
0
Alright, so everytime I run it it says primary part is not a valid member of part xXSwegL1feXx 0 — 4y
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) bostaffmanbulgaria1 89 — 4y
Ad

Answer this question