I made a roblox game where you are a ball, rolling around the map playing a gamemode similar to gorilla tag’s tag gamemode. What im trying to do is loop through all of the balls in a folder and check if they touch something, then if they touch a player and they are a tagger, they other player gets tagged.
This is the part im getting issues in, when a new round starts the for i,v loop still check if the untagged players touch something:
To understand easier, when 2 non-tagged players touch they both tag eachother.
for i,v:Part in workspace.Balls:GetChildren() do
if table.find(infectedPlayers,game.Players[v.Name]) then
v.Touched:Connect(function(t)
if not table.find(infectedPlayers,game.Players[t.Name]) then
infectedPlayerAdded:Fire(game.Players[t.Name])
end
end)
end
end
No, you see the problem is that when two NON-TAGGED players touch eachother, they both get tagged, and i think the issue is that the table is not updated in the loop. I have no idea how to update it, too.
You need to use table.insert for it. When the game starts, select a random player and insert him Into the table. If another player gets tagged, use the for loop. And I’m right. You’re not checking anything with the if statement
Best Way To Do Is The When The Game Starts And You Set The Ball Character To players, Create A Hitbox Part In Ball Character Make It Invisible and Set CanCollide To False Not CanTouch Property And Weld It To HumanoidRootPart, In ServerScriptService Add A Script This Script Will Do Your Work
--When Game Starts, Run This Script
--Connect Event For All Character
local HitPartName = "<HitBoxPartName>"
for _, __ in pairs(game.Players:GetChildren()) do
__.Character:WaitForChild(HitPartName).Touched:Connect(function(otherPart)
--Checks If Collided Part Is Another Player Or A Bots Hitbox Or Not
if otherPart.Name ~= HitPartName then return end
--Checks If Other Parts Parent Is A Cheracter Of a Player Or A Bot
if otherPart.Name.Parent:FindFirstChildOfClass("Humanoid") == nil then return end
local isATagger -- Use Your Logic Here, If This Charater Is A Tagger, Then It Will Be True
if isATagger then
--Set That Other Players Or Bots Character To Tagger, Using Your Own Logic Or Code Or Whatever
end
end)
end