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

Why is the touched function still laggy when using remote events?

Asked by 6 years ago

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?

0
there is no Touched function 1000anton 38 — 6y
0
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. Le_Teapots 913 — 6y
0
I'm not here to 'prove' myself, if I wasn't having the problem then I wouldn't be here. Witchest 48 — 6y
0
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. Le_Teapots 913 — 6y
View all comments (5 more)
0
You're the reason why this site has so many bad reviews. Your comments are invalid. Witchest 48 — 6y
0
Whoa hey there. Don't use ad hominem attacks GamingOverlord756 48 — 6y
1
I agree that this question is not construvtive but look here though --> https://devforum.roblox.com/t/repro-touched-events-delayed/38118 User#20388 0 — 6y
0
agreed, this site is terrible. Filled with stuck up 'know it alls' I think you should change your staff.. RobloxEmotes 3 — 6y
0
Thanks for sharing @RedcommanderV2 Le_Teapots 913 — 6y

1 answer

Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

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)
1
smart awesomeipod 607 — 6y
Ad

Answer this question