I think it's basic knowledge that the .Touched function ran on the client is delayed, but I've ran the .Touched script with a remote-event with a server script and the result is delayed for the person who shot the projectile but not for anyone else.
Does anyone know a way around this? I've tried everything I could think of. Will using remote functions instead make a difference?
While creating my gun script, I created a bullet trail using a server script and noticed that it delays for the client.
I solved the problem by creating a remotevent located in ReplicatedStorage so that all scripts can access it.
When the client fires the trail function, it sends the part to the server script. The server script :FireAllClients()
, sending the clients name who fired the event and part.
Local Script (located in tool)
local Tool = script.Parent local TrailEvent = ReplicatedStorage.Trail function CREATE_TRAIL() local Part = Instance.new('Part') Part.Parent = workspace TrailEvent:FireServer(Part) end
Server Script (located in workspace)
local TrailEvent = ReplicatedStorage.Trail function SEND_DATA(player, Part) TrailEvent:FireAllClients(player.Name, Part) end TrailEvent.OnServerEvent:connect(SEND_DATA)
Local Script (located in a Player's PlayerScripts)
local TrailEvent = ReplicatedStorage.Trail function TRAIL(playername, part) if game.Players.LocalPlayer.Name ~= playername then -- Basically like a filter. It clones the trail part for every client except the player who fired the event local trail = part:Clone() trail.Parent = workspace end end TrailEvent.OnClientEvent:connect(TRAIL)