The title may not be very explanatory but I’m having a really big problem with a script right now and its the biggest thing thats slowing development for my game,
When I want a click detector to activate it would teleport a player to a position but I’ve added a party system so that people of the same party would get teleported to the same position together, However so far I’ve only found problems as when it’s clicked it scans through every players party and teleports everyplayer even if they are not in the same party to the position which I dont want as I only want the player clicking its party to get scanned through and checked for any members.
Players = game:GetService("Players")
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local folders = game.ReplicatedStorage.Invites
local root = player.Character:FindFirstChild("HumanoidRootPart")
local Workspace = game:GetService("Workspace")
if root then
game.ReplicatedStorage.JudgementHall.Parent = workspace
root.CFrame = CFrame.new(-2808.753, 1550.77, -3419.949)
script.Parent.Parent.Parent["J-FIGHT"].Parent = game.ServerStorage
game.ServerStorage["J-NOFIGHT"].Parent = game.Workspace.Areas.JudgementHall.IMPORTANT
game.Workspace.JudgementHall.SilenceMusicGate.Parent = game.ServerStorage
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if root then
for i,v in pairs(game.Players:GetPlayers()) do
if v:IsA("Player") then
local f = game.ReplicatedStorage.Invites[v.Name.."'s Group"]
if f.Players then
for i,b in pairs(f:GetChildren()) do
if b:IsA("StringValue") then
local realplr = game.Players[b.Value]
local realchar = realplr.Character
realchar.HumanoidRootPart.CFrame = root.CFrame
end
end
end
end
end
end
end)
end
end)
This is the script it is a serverscript, the thing I think is the problem is the i,v pairs get players do as I think it scans through EVERY player when I want it to only scan through the singular player and I dont know what could be causing it as I’ve tried many solutions so help and hopefully success to me fixing this would be greatly appreciated.