I’m making a spawning system where mushrooms/sticks and whatnot will spawn on the map randomly. It work the problem is the script in each one will only run once. There is only one local script in starter player scripts, is that the issue? There are dozens of the "script"s in the workspace once cloned. The first cloned script is the only one that works the rest don’t run.
script not running
game.ReplicatedStorage.SendingCharacter.OnServerInvoke = function(player, plr, character)
while wait(.2) do
local pickedUp = script.Parent:GetAttribute("PickedUp")
local distance = (character.Head.Position - script.Parent.Position).magnitude
if distance <= 10 and pickedUp == false then
local pos = Instance.new("BodyPosition")
pos.Parent = script.Parent
pos.P = 30000
while wait(.1) do
pickedUp = true
script.Parent.Anchored = false
pos.Position = Vector3.new(character.Head.Position.X, character.Head.Position.Y, character.Head.Position.Z)
end
end
end
end
LocalScript
local player = game.Players.LocalPlayer
local character = player.character
game.ReplicatedStorage.SendingCharacter:InvokeServer(player, character)