RemoteEvent delay

I was trying to make a tesla that can open its two front door using the GUI textbuttons but however, when i try to do it, the door isn’t opened immediately and it also cannot be closed too.
Note: when the GUI textbutton is clicked, the localscript will send signals to the server either to close or open the doors using remote event.
Client script:

[code]> local DoorOpen = script.Parent

local leftfront = workspace.TeslaCyberTruck.leftfront

print(leftfront.Parent)

DoorOpen.leftfrontopenclose.MouseButton1Up:Connect(function()

leftfront:FireServer()

end)

local rightfront = workspace.TeslaCyberTruck.rightfront

DoorOpen.rightfrontopenclose.MouseButton1Up:Connect(function()

rightfront:FireServer()

end)[/code]
serverscript:
local leftfront = workspace.TeslaCyberTruck.leftfront
leftfront.OnServerEvent:Connect(function(player)
if workspace.TeslaCyberTruck.DoorServo.leftfront.CurrentAngle == 0 then
print(“openning left front door”)
workspace.TeslaCyberTruck.DoorServo.leftfront.TargetAngle = 30
workspace.TeslaCyberTruck.leftfrontdoor.CanCollide = false
workspace.TeslaCyberTruck.leftfrontglass.CanCollide = false
repeat
wait()
print(workspace.TeslaCyberTruck.DoorServo.leftfront.CurrentAngle)
print(“hasn’t reached the desire angle”)
until workspace.TeslaCyberTruck.DoorServo.leftfront.CurrentAngle >= 30
workspace.TeslaCyberTruck.leftfrontdoor.CanCollide = true
workspace.TeslaCyberTruck.leftfrontglass.CanCollide = true
return
elseif workspace.TeslaCyberTruck.DoorServo.leftfront.CurrentAngle == 30 then
print(“Closing left front door”)
workspace.TeslaCyberTruck.DoorServo.leftfront.TargetAngle = 0
workspace.TeslaCyberTruck.leftfrontdoor.CanCollide = false
workspace.TeslaCyberTruck.leftfrontglass.CanCollide = false
repeat
wait()
print(workspace.TeslaCyberTruck.DoorServo.leftfront.CurrentAngle)
print(“hasn’t reached the desire angle”)
until workspace.TeslaCyberTruck.DoorServo.leftfront.CurrentAngle == 0
workspace.TeslaCyberTruck.leftfrontdoor.CanCollide = true
workspace.TeslaCyberTruck.leftfrontglass.CanCollide = true
return
end
end)
local rightfront = workspace.TeslaCyberTruck.rightfront
rightfront.OnServerEvent:Connect(function(player)
if workspace.TeslaCyberTruck.DoorServo.rightfront.CurrentAngle == 0 then
print(“openning right front door”)
workspace.TeslaCyberTruck.DoorServo.rightfront.TargetAngle = -30
workspace.TeslaCyberTruck.rightfrontdoor.CanCollide = false
workspace.TeslaCyberTruck.rightfrontglass.CanCollide = false
repeat
wait()
print(workspace.TeslaCyberTruck.DoorServo.rightfront.CurrentAngle)
print(“hasn’t reached the desire angle”)
until workspace.TeslaCyberTruck.DoorServo.rightfront.CurrentAngle <= -30
workspace.TeslaCyberTruck.rightfrontdoor.CanCollide = true
workspace.TeslaCyberTruck.rightfrontglass.CanCollide = true
return
elseif workspace.TeslaCyberTruck.DoorServo.leftfront.CurrentAngle == -30 then
print(“Closing right front door”)
workspace.TeslaCyberTruck.DoorServo.rightfront.TargetAngle = 0
workspace.TeslaCyberTruck.rightfrontdoor.CanCollide = false
workspace.TeslaCyberTruck.rightfrontglass.CanCollide = false
repeat
wait()
print(workspace.TeslaCyberTruck.DoorServo.rightfront.CurrentAngle)
print(“hasn’t reached the desire angle”)
until workspace.TeslaCyberTruck.DoorServo.rightfront.CurrentAngle == 0
workspace.TeslaCyberTruck.rightfrontdoor.CanCollide = true
workspace.TeslaCyberTruck.rightfrontglass.CanCollide = true
return
end
end)

It’s simple. Just take away the remote event. And use a server script in the gui, it doesn’t matter if the gui is in the playergui.

Uhm, you made a good point, that is interesting

1 Like

Yes, but it would work. You can get everything you can get in a local script.

To get player just say script.Parent until you get to player

To get character just say plr:GetCharacterFromPlayer()

It’s simple.

1 Like

Did you try to put the remote events in ReplicatedStorage? If not, put the remote events in ReplicatedStorage and see if it will do any better.

Oh, i figured out the problem.It is not about the remote event, it is about the angle, i notice it when i print the current angle that it couldn’t be perfect as 30 degrees or 0 as expected, it is always slightly lower or higher

1 Like

Please never do this lol. Exploiters can do god-knows-what…

One remote event wont matter. Most exploiters can already do god knows what.

Yeah, they can open or close the door, that is all they can do