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
local trail = part:Clone()
trail.Parent = workspace
end
end
TrailEvent.OnClientEvent:connect(TRAIL)
9 comments
there is no Touched function
Interesting, I didn't know the .Touched function ran on the client is delayed. Mind posting a link to an article/wiki_post proving your statement? Thanks beforehand.
I'm not here to 'prove' myself, if I wasn't having the problem then I wouldn't be here.
Very well then, your statement therefor is FALSE: .Touched DOES NOT delay when triggered client-side. This question makes no sense and is not constructive.
You're the reason why this site has so many bad reviews. Your comments are invalid.
Whoa hey there. Don't use ad hominem attacks
I agree that this question is not construvtive but look here though --> https://devforum.roblox.com/t/repro-touched-events-delayed/38118
agreed, this site is terrible. Filled with stuck up 'know it alls' I think you should change your staff..
Thanks for sharing @RedcommanderV2