So i had an idea on making a localscript that gives you gear if your name matches what is in the script, but its not working. i have it in StarterPlayerScripts and it doesnt do anything or gives no errors when i play test it.
here is the localscript:
local plr = game.Players.LocalPlayer
local gears = game.ServerStorage:GetDescendants()
local userName = "Drewel112233"
if plr.Name == userName then
for i = 1, #gears do
if gears[i]:IsA("Tool") then
gears[i]:Clone().Parent = plr:WaitForChild("Backpack")
gears[i]:Clone().Parent = plr:WaitForChild("StarterGear")
end
end
else
warn("there is a problem!")
end
the Warn() i put at the end doesnt ouput either.
I feel like it has something to do with where the LocalScript is at, but im not sure.
i moved one gear into ReplicatedStorage, and i got infinte yields on both gears[i]:Clone().Parent = plr:WaitForChild("Backpack") and gears[i]:Clone().Parent = plr:WaitForChild("StarterGear")
i did. and doing that caused it to do infinte yields.
also, an admin command model adds some folders to ReplicatedStorage. im not sure if i need to change the thing to get all children cause i know GetDescendents() gets every child in every instance, and i also dont know yet if im gonna create a folder for different types of gears to live at.
Instead of doing this in a LocalScript, I recommend using a ServerScript
game:GetService("Players").PlayerAdded:Connect(function(Player)
if Player.Name == "Drewel112233" then
for i,v in pairs(game:GetService("ServerStorage "):GetChildren()) do if v:IsA("Tool") then v:Clone().Parent = Player.StarterPack
end
end
end)
If you do this on the client, no one else will see that you have the gear. You’ll have to use a Script in ServerScriptService. LocalPlayer is nil in Scripts, so you’ll have to use PlayerAdded.