hello i am pretty new to remote events/functions and i am using Quasiducks lightning beams and I made it so the lightning bolt plays when you click a button it fires a remote event making a lightning bolt in the server and then playing it to all clients. It works but it has a delay since its running of the server.
Is there any way to make it hide the delay by running on client and sending it to the server so its only delayed for others but not you?
Local script:
local event = game.ReplicatedStorage.RemoteEvent
local remoteFunction = game.ReplicatedStorage.RemoteFunctionTest
local LightningBolt = require(game.Workspace.Model.LightningBolt)
local LightningSparks = require(game.Workspace.Model.LightningBolt.LightningSparks)
local LightningExplosion = require(game.Workspace.Model.LightningBolt.LightningExplosion)
local button = game.Workspace.button
local click = button.ClickDetector
function onClick()
event:FireServer()
end
event.OnClientEvent:Connect(function()
local NewBolt2 = LightningBolt.new(workspace.Model.Part4.Attachment4, workspace.Model.Part3.Attachment3, 20)
NewBolt2.CurveSize0 = math.random(-20,20)
NewBolt2.CurveSize1 = math.random(-20,20)
NewBolt2.PulseSpeed = 15
NewBolt2.PulseLength = 5
NewBolt2.FadeLength = 0.3
NewBolt2.MaxRadius = 2
NewBolt2.Frequency = 1
NewBolt2.Color = Color3.new(0.854902, 0.701961, 0.188235)
local newSparks = LightningSparks.new(NewBolt2, 40)
newSparks.LightningBolt = NewBolt2
local newExplosion = LightningExplosion.new(workspace.Model.Part3.Position, 1, 5, Color3.new(0.854902, 0.701961, 0.188235), Color3.new(0.854902, 0.701961, 0.188235))
end)
click.MouseClick:Connect(onClick)
Server:
local event = game.ReplicatedStorage.RemoteEvent
local remoteFunction = game.ReplicatedStorage.RemoteFunctionTest
local LightningBolt = require(game.Workspace.Model.LightningBolt)
local LightningSparks = require(game.Workspace.Model.LightningBolt.LightningSparks)
local LightningExplosion = require(game.Workspace.Model.LightningBolt.LightningExplosion)
event.OnServerEvent:Connect(function(player)
local NewBolt2 = LightningBolt.new(workspace.Model.Part4.Attachment4, workspace.Model.Part3.Attachment3, 20)
NewBolt2.CurveSize0 = math.random(-20,20)
NewBolt2.CurveSize1 = math.random(-20,20)
NewBolt2.PulseSpeed = 15
NewBolt2.PulseLength = 5
NewBolt2.FadeLength = 0.3
NewBolt2.MaxRadius = 2
NewBolt2.Frequency = 1
NewBolt2.Color = Color3.new(0.854902, 0.701961, 0.188235)
local newSparks = LightningSparks.new(NewBolt2, 40)
newSparks.LightningBolt = NewBolt2
local newExplosion = LightningExplosion.new(workspace.Model.Part3.Position, 1, 5, Color3.new(0.854902, 0.701961, 0.188235), Color3.new(0.854902, 0.701961, 0.188235))
event:FireAllClients(player)
end)