So, I made like a NPC basketball defender once you touch the brick, which is z1. The script is in z1. Now, this script works, but I think and it seems it only works for the first person who enters the server, or who touches z1. How do I allow it to work with every player rather than just 1, and efficiently? The other variables are for later on, like NPC defense. I've been on this problem for a week and it is rather frustrating and I'm falling behind on my deadline of when I wish to finish this.
LW = game.Workspace.zone.LW
Mid = game.Workspace.zone.Mid
OPG = game.Workspace.zone.OPG
RW = game.Workspace.zone.RW
opg1 = false
lw1 = false
mid1 = false
rw1 = false
v = game.Players:GetPlayers()
f = game.Players:GetFullName()
LeftArm = game.Workspace.zone.OPG["Left Arm"]
LeftLeg = game.Workspace.zone.OPG["Left Leg"]
RightArm = game.Workspace.zone.OPG["Right Arm"]
RightLeg = game.Workspace.zone.OPG["Right Leg"]
Head = game.Workspace.zone.OPG.Head
HumanoidRootPart = game.Workspace.zone.OPG.HumanoidRootPart
Torso = game.Workspace.zone.OPG.Torso
z1 = game.Workspace.zone.Zones.z1
z2 = game.Workspace.zone.Zones.z2
z3 = game.Workspace.zone.Zones.z3
z4 = game.Workspace.zone.Zones.z4
z5 = game.Workspace.zone.Zones.z5
game.Players.PlayerAdded:connect(function()
local plr = game.Players:GetPlayers()
local f= game.Players:GetChildren()
for i = 1, #f do
print(f[i])
end
end)
z1.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if opg1 == false and hit.Parent:FindFirstChild("Basketball") then
opg1 = true
print("Found Player")
local plr = game.Players:GetPlayers()
local f= game.Players:GetChildren()
for i = 1, #f do
if f[i].Character then
playerinGame = f[i].Character
end
while opg1 == true do
wait(0.5)
OPG.Humanoid:MoveTo(playerinGame.Basketball.Handle.Position - Vector3.new(2,0,0))
end
end
else
print("Did not find player")
end
end)
z5.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if opg1 == true and hum and lw1 == false and rw1 == false and mid1 == false then
opg1 = false
lw1 = false
rw1 = false
mid1 = false
game.Workspace.zone.Zones.z1:Destroy()
OPG.Humanoid.WalkToPoint = Vector3.new(-1.344, 13.419, -26.512)
wait(3)
local s= game.Lighting.zone.Zones.z1:Clone()
s.Parent = game.Workspace.zone.Zones
z1.Parent = game.Workspace.zone.Zones
else
return false
end
end)

2 comments
There's a lot wrong with this script. You're going to have a ton a problems. Give us one problem at a time, not all at once. Good luck.
Like what? And I did state my problem, it only works for the player that first touches it, or joins. It's very rude for you to say I would have 'a ton' wrong with this, as I haven't encountered any issues. You don't point someones problems out then don't help the person.