You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to loop through every player, and if the player I am looping through, is me then I want to skip to the next player.
- What is the issue? Include screenshots / videos if possible!
I have this code
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
repeat wait() until game:IsLoaded()
wait(10)
print("starting")
local OurChar = Player.Character or Player.CharacterAdded:Wait()
local OurHRP = OurChar:WaitForChild("HumanoidRootPart")
local Tag = workspace:FindFirstChild(Player.Name .. " tag")
if Tag then
Tag:Destroy()
else
warn("tag couldn't be destroyed")
end
game.Players.PlayerAdded:Connect(function(player345345)
if player345345.Name == Player.Name then -- for some reason this is always true
warn("same name! " .. player345345.Name .. " and " .. Player.Name) -- it always returns with this
return
else
warn("different name!")
end
player345345.CharacterAdded:Connect(function(Dummy)
print("e")
local HRP = Dummy:WaitForChild("HumanoidRootPart")
local NearPlayer = false
RunService.RenderStepped:Connect(function()
if Player:DistanceFromCharacter(HRP.Position) < 10 then
print("in range")
NearPlayer = true
workspace:FindFirstChild(Dummy.Name .. " tag").Enabled = true
else
NearPlayer = false
workspace:FindFirstChild(Dummy.Name .. " tag").Enabled = false
end
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Key = Input.KeyCode
if Key == Enum.KeyCode.E and NearPlayer == true then
if Player.Name == game.ReplicatedStorage.CurrentMonster.Value then
game.ReplicatedStorage:FindFirstChild("Kill"):FireServer(Dummy)
print("fired")
else
print("now reviving")
game.ReplicatedStorage.Reviv:FireServer(Dummy)
end
end
end
end)
end)
end)
for i, v in pairs(game.Players:GetPlayers()) do
if v.Name == Player.Name then
warn("same name! " .. v.Name .. " and " .. Player.Name)
return
else
warn("different name!")
end
local Dummy = v.Character or v.CharacterAdded:Wait()
print("e")
local HRP = Dummy.HumanoidRootPart
local NearPlayer = false
RunService.RenderStepped:Connect(function()
if Player:DistanceFromCharacter(HRP.Position) < 10 then
print("in range")
NearPlayer = true
workspace:FindFirstChild(Dummy.Name .. " tag").Enabled = true
else
NearPlayer = false
workspace:FindFirstChild(Dummy.Name .. " tag").Enabled = true
end
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Key = Input.KeyCode
if Key == Enum.KeyCode.E and NearPlayer == true then
if Player.Name == game.ReplicatedStorage.CurrentMonster.Value then
game.ReplicatedStorage:FindFirstChild("Kill"):FireServer(Dummy)
print("fired")
else
print("now reviving")
game.ReplicatedStorage.Reviv:FireServer(Dummy)
end
end
end
end)
end
But when I run that, it ONLY loops through the current player. Even when there is a lot of people.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I can’t find any solutions.
I’m sorry if this makes no sense, I don’t get it either and I’m trying to explain it the most I can.
Output: