So, I couldn’t find close to any info of this on the devforum. I may have just been looking in the wrong places, however…
Does anybody know the most efficient way to reduce memory and lag, whilst checking if a specific part has been touched or is being touched? My current method uses a good bit a memory, as it runs on the client and checks if the part was touched, and if it was, it uses a RemoteEvent and sends a signal to the server. My thoughts were that there was a better option here, but I’m not sure.
A few things, I guess it is good to keep memory down; however, from my experience, high memory doesn’t really affect gameplay. The other thing is, can you provide some code? I can think of many solutions, but I don’t know which would work for you if I’m not sure what you are attempting to do.
Thanks for the tip about memory. I always just try to tend to keep it down as much as I can for the sake of lower end devices. As far as the code goes, here you go
Local Script
HumanoidRootPart.Touched:Connect(function(part) --- Getting every part that touches the player/ Everytime the player touches a part
if part ~= nil then --- Just checking if it exists
if part:FindFirstChild("Infect") then --- Find a value inside the part
game.ReplicatedStorage.Infect:FireServer(Player, Character, Humanoid, part.Name) --- Fire the server
end
end
end
The server script doesn’t really matter to this though, its really just a receiver.
It depends on what you’re trying to do, if you’re trying to get it seen by everyone, and also the server, then replicate it on the server. If it’s client sided, replicate it onto the client.