Well, I wanna get my forloop variable to another function where I fire a remoteevent, but I cannot get it over and I cannot put it in the forloop. How do I do to fire it with the forloop variable?
Script:
script.Parent.MouseButton1Click:Connect(function()
local dataTable = {}
for i,proof in pairs(script.Parent.Parent.Proof:GetChildren()) do
end
local Username = script.Parent.Parent.Username
local Reason = script.Parent.Parent.Reason
game.ReplicatedStorage.AdminEvents.KickEvent:FireServer(Username, Reason, Proof)
end)
You place the line game.ReplicatedStorage.AdminEvents.KickEvent:FireServer(Username, Reason, proof) inside the for loop block. Is that what you want?
script.Parent.MouseButton1Click:Connect(function()
local dataTable = {}
local Username = script.Parent.Parent.Username
local Reason = script.Parent.Parent.Reason
for i,proof in pairs(script.Parent.Parent.Proof:GetChildren()) do
game.ReplicatedStorage.AdminEvents.KickEvent:FireServer(Username, Reason, Proof)
end
end)
Well, isn’t that going to fire the remoteevent multiple times if there are multiple things in the v value for forloop as I am fetching script.Parent.Parent.Proof:GetChildren(), it has multiple values, wouldn’t that fire it multiple times?
Well, I am unsure what you meant in the main question, so I assumed you wanted that…?
If not, maybe these would work for you:
If you want the proofs out, then I don’t know what you will be doing with the for loop, but either FireServer with the entire table of script.Parent.Parent.Proof:GetChildren() in it.
script.Parent.MouseButton1Click:Connect(function()
local dataTable = {}
local tableOfProofs = {}
local Username = script.Parent.Parent.Username
local Reason = script.Parent.Parent.Reason
for i,proof in pairs(script.Parent.Parent.Proof:GetChildren()) do
-- add validation stuff here or other things idk?
table.insert(tableOfProofs, proof)
end
game.ReplicatedStorage.AdminEvents.KickEvent:FireServer(Username, Reason, tableOfProofs)
end)
So, for an example if I would have a variable inside for i,v like this:
for i,v in pairs(script.Parent.Parent.Proof:GetChildren()) do
local Proof = v
end
I wanna put the Proof variable inside another function like this:
script.Parent.MouseButton1Click:Connect(function()
local dataTable = {}
for i,v in pairs(script.Parent.Parent.Proof:GetChildren()) do
local Proof = v
end
local Username = script.Parent.Parent.Username
local Reason = script.Parent.Parent.Reason
game.ReplicatedStorage.AdminEvents.KickEvent:FireServer(Username, Reason, Proof)
end)
this wont work, Proof is a local variable meaning it wont carry over pass that for loop. even if you make Proof global that wont work either because it will be resetting the variable every time you loop
do what @Y_VRN if you want it to not fire multiple times and send everything in Proof’s children