Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

RemoteEvent don't work with wait() ?

Hello everyone,

I got an issue with my OnServerEvent, I want to make the OnServerEvent wait for 1 second but that seem to not work.

Here is my script Server Sided :

work.OnServerEvent:Connect(function(player)
	local MoneyStore = datastore2("Money", player)
	local HumRootPart = player.Character:WaitForChild("HumanoidRootPart")
	local ecran = game:GetService("Workspace").Buildings.maison.PCStart.ecran
	if (ecran.Position - HumRootPart.Position).magnitude < 5 then
		MoneyStore:Increment(1)
		wait(1)
	end
end)

Here is my script Client Sided :

UIS.InputBegan:connect(function(input)
	if input.keyCode == Enum.KeyCode.E then
		if (ecran.Position - HumRootPart.Position).magnitude < 5 and cam == 1 then
			controls:Disable()
			camera.CameraType = "Scriptable"
			camera.CFrame = CFrame.new(camera1.Position, ecran.Position)
			cam = 2
			while cam == 2 do 	
				work:FireServer()
			end

I tried to add print() to see if the wait really skip and I got two instant print which mean that the wait is skipped, I also saw that my game crash... So I was wondering if the wait() function don't work with Remote Events ?

Thanks in advance.

1 comment

0

You could use a RemoteFunction.

1 answer

Thank you for your answer I will try it :D

Edit: That works perfectly thanks you again !

This discussion is preserved as it was. New answers, comments, and votes are closed.