Hello. I am trying to make a server script wait a set amount of time that I sent over a remote event from local script (offset) before firing the client but every time I run it with the wait(offset)
it says attempt to yield across metamethod/C-call boundary
. I have no clue what I am doing wrong or how to fix this. Here is my code for the server script.
local E = game.ReplicatedStorage.Events
local SA = E:FindFirstChild("SA")
SA.OnServerEvent:Connect(function(player, keyName, offset)
keyName:gsub('(%a*):(.*)', function (first, second)
print(('\'%s\' : \'%s\''):format(first, second))
print("Note Recieved: "..keyName)
local Key = game.ReplicatedStorage.key:Clone()
local Start = workspace.Game:FindFirstChild(first.."Start")
local Finish = workspace.Game:FindFirstChild(first.."Finish")
local Distance = (Start.Position - Finish.Position).magnitude
Key.Parent = workspace.Notes
Key.Name = keyName
Key:SetAttribute("Key", first)
Key:SetAttribute("Time", offset)
wait(offset)
Key:SetAttribute("Hittable", true)
SA:FireClient(player, keyName, Start, Finish, Distance)
end)
end)