it keep erroring "attempt to call a string value"
local rep = game:GetService("ReplicatedStorage") local userinput = game:GetService("UserInputService") local Print = function(p) print("Lazy") end remotes = { Print = rep:WaitForChild("RemoteEvent") } game.Players.PlayerAdded:Connect(function(p) p.CharacterAdded:Connect(function(c) for name, event in pairs (remotes) do event.OnServerEvent:Connect(name) end end) end)
You're calling the variable/name "Print" instead of indexing the function and calling that in your onserverevent. Try this. It should work. Though. I don't recommend doing this using tables. It'll slow down the script. Since the in pairs loop, loops through the table, it takes time. There is a solution for that though.
local rep = game:GetService("ReplicatedStorage") local userinput = game:GetService("UserInputService") local Print = function(p) print("Lazy") end remotes = { [Print] = rep:WaitForChild("RemoteEvent") } game.Players.PlayerAdded:Connect(function(p) p.CharacterAdded:Connect(function(c) for name, event in pairs (remotes) do event.OnServerEvent:Connect(name) end end) end)