Hi! This is a bit of a simple error, but is there a way to stop this while loop so the Teddy Bear gets cloned into the backpack only once? Thanks!
LocalScript:
local rs = game:GetService("ReplicatedStorage")
while wait(5) do
local Players = game:GetService('Players')
local player = game.Players.LocalPlayer
local children = Players:GetChildren()
for i, child in pairs(children) do
if player:IsFriendsWith(child.UserId) then
rs["Teddy Bear"]:Clone().Parent = player.Backpack
end
break
end
end
local bear = game.ReplicatedStorage:WaitForChild("Teddy Bear")
for i,v in pairs(game.Players:GetPlayers()) do
if game.Players.LocalPlayer:IsFriendsWith(v.UserId) then
bear:Clone()
bear.Parent = game.LocalPlayer.Backpack
end
end
game.Players.PlayerAdded:Connect(function(plr)
if game.Players.LocalPlayer:IsFriendsWith(plr.UserId) then
bear:Clone()
bear.Parent = game.LocalPlayer.Backpack
end
end)