Im have this script that checks how many players are in a part (capture zone) and their team, now when only one player is in the server it doesnt lag at all, but as soon as another player joined the fps for the player inside the zone dropes to 20 and when the other player is in the zone aswell it drops to 12 for both.
I have no idea why this is the cas so any help is welcome.
local Players = game:GetService('Players')
local Part = script.Parent
local PlayersTouchingPart = {}
Part.Touched:Connect(function(hit)
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player and not table.find(PlayersTouchingPart ,Player.Name) then --Check if player exists and if the player is already in the table
table.insert(PlayersTouchingPart, Player.Name)
if tostring(Player.Team) == "Team Red" then
script.Parent.RedTeam.Value += 1
print(Player)
print(script.Parent.RedTeam.Value)
end
end
end)
Part.TouchEnded:Connect(function(hit)
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player and table.find(PlayersTouchingPart ,Player.Name) then -- Check if the player is in the table
table.remove(PlayersTouchingPart, table.find(PlayersTouchingPart, Player.Name))
if tostring(Player.Team) == "Team Red" then
script.Parent.RedTeam.Value -= 1
print(Player)
print(script.Parent.RedTeam.Value)
end
end
end)
I copied the code into a new baseplate, personally didn’t have any framerate drops for 1 player, or 2 players or 3.
Perhaps there is something else in the game causing the drop in frame rate?
Also, do you normally have frame rate issues in either Roblox or Studio?
“Perhaps there is something else in the game causing the drop in frame rate?”
i dont think so as the game ran perfectly fine before i added this script
and I never really have fps drops in roblox or studio
Try copying the capture zones as well as the script into a fresh baseplate, and test to see if there is any frame rate issues there for you. If there isn’t, then I reckon that some other script in your game is interacting with the new capture zones you’ve added in a way which causes the frame rate to drop.