or just replace the local script to a script
Yay! It works! Thank you so much! And by the way, I checked in server view and the animations ARE automatically replicated. :D
Now i will just make it fly :)
Make a script in ServerScriptService and replace the code with that (And delete the local script in StarterPlayerScripts)
local Players = game:GetService("Players")
local Connections = {}
Players.PlayerAdded:Connect(function(plr)
Connections[plr] = {}
table.insert(Connections[plr], plr.CharacterAdded:Connect(function(char)
print("a")
for i = 1, 3 do
local randomtool = game.ReplicatedStorage.Tools:GetChildren()[math.random(1,#game.ReplicatedStorage.Tools:GetChildren())]
randomtool.Parent = plr.Backpack
end
table.insert(Connections[plr], char.Humanoid.Died:Connect(function()
for i, v in plr.Backpack:GetChildren() do
v.Parent = game.ReplicatedStorage.Tools
end
if char:FindFirstChildWhichIsA("Tool") then
char:FindFirstChildWhichIsA("Tool").Parent = game.ReplicatedStorage.Tools
end
end))
end))
end)
Players.PlayerRemoving:Connect(function(plr)
local PlayerConnections = Connections[plr]
if PlayerConnections then
for _, Connection in PlayerConnections do
Connection:Disconnect()
end
table.clear(PlayerConnections)
Connections[plr] = nil
end
end)
I find it way better doing it in a server side script and not in a client side script
Maybe. But the reason it was being parented was because it was clientsided, i didnt want any rpeats.
Also, what is the Connections thingy doing?
Disconnecting the connections of the player (plr.CharacterAdded and char.Humanoid.Died) when the player leaves for no memory leaks
Whats a memory leak? 30charlimit
i dont get it it says luau does it for you