Hello, I am making a system that auto-assigns players to a team. And if you’re on a certain team it will give you a sort of starter pack. This is all done on a server sided script. I have tried looking up this problem, however the solutions for them didnt seem to work for me. The cloned tools contain a localscript and a normal script, both cease to work upon being cloned and parented.
local players = game:GetService("Players")
local teams = game:GetService("Teams")
local pack = game:GetService("ServerStorage"):WaitForChild("Weapons"):WaitForChild("GuardStarterPack")
local maxplayersguards = 6
local guy
players.PlayerAdded:Connect(function(player)
local amount = 0
for i,v in pairs(teams.Guards:GetPlayers()) do
wait()
amount = amount + 1
end
if amount < maxplayersguards then
player.Team = teams.Guards
local stor = game:GetService("ServerStorage")
local char = stor.Police:Clone()
guy = char
char.Name = "StarterCharacter"
wait()
char.Parent = game.StarterPlayer
player:LoadCharacter()
guy:Destroy()
for i,v in pairs(pack:GetChildren()) do
local tool
tool = v
tool:Clone()
tool.Parent = player.Backpack
end
print("Character loaded successfully")
end
end)
I don’t think it should. It waits for the character to load essentially. But, if it’s off then it might. My bad. Let me re-look over the code. It’s weird how it stops working. Are there any errors in the output?
Yes, the scripts located inside the tool use script.Parent. However script.Parent isn’t defined as a variable inside of the scripts. Should I change that?
Darn, that is so weird. Am I able to by chance see your scripts for the tool? Try using print statements within your local/global scripts and see if anything is being printed.
I tried doing that and nothing gets printed. The main code is run in the local script which is powered by 1 big Tool.Equipped function. Could this possibly be something with filteringenabled or some other security thing?
So, if nothing is being printed when you do that, it’s probably some form of security thing. Try doing tool.Activated instead of Equipped. Then click and see if it runs when you have the tool equipped.
You didn’t put the tool clone in a variable so the clone wasn’t being set to the backpack ,but rather the original tool in the folder, maybe that’s the issue?
Also, the tools wont appear after a respawn, you have to also put it in your starterGear, so do this as well