Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix client to server remote event delay?

Asked by
TtuNkK 37
3 years ago

I'm coding it where a keyboard input would cause a fire to a server script, creating sort of a forcefield surrounding the player by using cframes and welding. However, it appears that there is a delay because I would be teleported a few steps back when the forcefield appears.

Does anyone know how to fix this?

Local Script

UIS.InputBegan:Connect(function(input, isTyping)
    if isTyping then
        return
    elseif input.KeyCode == Enum.KeyCode.F then
        if debounce == false and isBroken.Value == false then
            if isActive == false then
                ended = false
                isActive = true
                Block:FireServer(isActive)
            end
        end
    end
end)

Server Script

local blockfield = Meshes:WaitForChild("BlockField"):Clone()
blockfield.CFrame = hrp.CFrame
blockfield.Parent = Character
local weld = Instance.new("ManualWeld")
weld.Part0 = blockfield
weld.Part1 = hrp
weld.C0 = weld.Part0.CFrame:toObjectSpace(weld.Part1.CFrame)        
weld.Parent = weld.Part0

Answer this question