Hi there, I have a script that continuously fires a remote when a key is held. The issue is, is that it sometimes lags out and even crashes. I’m trying to make a part movewhile the remote is firing, but it’s unsmooth yet very laggy. How can I make the movement of a part a lot smoother when a remote is fired while also maintaining the lowest remotes fired?
ls
local UIS = game:GetService("UserInputService")
local forward = game.ReplicatedStorage:WaitForChild("forward")
local reverse = game.ReplicatedStorage:WaitForChild("reverse")
local left = game.ReplicatedStorage:WaitForChild("left")
local right = game.ReplicatedStorage:WaitForChild("right")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.T then
forward:FireServer(true)
end
if input.KeyCode == Enum.KeyCode.G then
reverse:FireServer(true)
end
if input.KeyCode == Enum.KeyCode.F then
left:FireServer(true)
end
if input.KeyCode == Enum.KeyCode.H then
right:FireServer(true)
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.T then
forward:FireServer(false)
end
if input.KeyCode == Enum.KeyCode.G then
reverse:FireServer(false)
end
if input.KeyCode == Enum.KeyCode.F then
left:FireServer(false)
end
if input.KeyCode == Enum.KeyCode.H then
right:FireServer(false)
end
end)
ss
local isForward = false
local isReverse = false
local isLeft = false
local isRight = false
forward.OnServerEvent:Connect(function(player,pressed)
if player.Name == "vxsqi" then
isForward = pressed
end
end)
reverse.OnServerEvent:Connect(function(player,pressed)
if player.Name == "vxsqi" then
isReverse = pressed
end
end)
left.OnServerEvent:Connect(function(player,pressed)
if player.Name == "vxsqi" then
isLeft = pressed
end
end)
right.OnServerEvent:Connect(function(player,pressed)
if player.Name == "vxsqi" then
isRight = pressed
end
end)
game:GetService("RunService").Heartbeat:Connect(function()
if isForward then
Part0.CFrame = Part0.CFrame * CFrame.new(0,0,0.5)
end
if isReverse then
Part0.CFrame = Part0.CFrame * CFrame.new(0,0,-0.5)
end
if isLeft then
Part0.CFrame = Part0.CFrame * CFrame.Angles(0,0.025,0)
end
if isRight then
Part0.CFrame = Part0.CFrame * CFrame.Angles(0,-0.025,0)
end
end)