I wanted to remove the table using the unpack() function, but I couldn’t do anything because it gives the error ‘invalid argument’. Can I somehow keep all the values from the table?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayerCall = ReplicatedStorage.PlayerCall
PlayerCall.OnServerEvent:Connect(function(plr,EventName,...)
local Args = unpack(...) --(...) is a table with arguments
local Called = false
for i,v in pairs(game.ReplicatedStorage:GetDescendants()) do
if v.Name==EventName then
v:Fire(Args)
Called=true
break
end
end
if Called then
warn("success call!")
else
warn("unsuccess call!")
end
end)
The “…” is not a table at first, you gotta convert it to a table with table.pack
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayerCall = ReplicatedStorage.PlayerCall
PlayerCall.OnServerEvent:Connect(function(plr,EventName,...)
local Args = unpack(table.pack(...))
local Called = false
for i,v in pairs(game.ReplicatedStorage:GetDescendants()) do
if v.Name==EventName then
v:Fire(Args)
Called=true
break
end
end
if Called then
warn("success call!")
else
warn("unsuccess call!")
end
end)