Is it ok to use this method for effects and what not?

So, I am making a fps game.
A good game consists of good sound design and good visuals, so I thought of a way that can make clean effects and sounds on the client without using any more remote events or other stuff. What I did is create a folder in the workspace called “Client_Workspace” and then when i needed to, created a cframevalue in the folder. The client would use childadded to see this new cframevalue and then make sounds, visuals etc according to the value of the cframevalue.

The reason I am not using remote events is that if your constantly firing your gun every 0.1 seconds to the server and then the server would fire the remote back to all the clients, that would be laggy and you would get extreme ping spikes. It would be even worse if you had multiple players. If you had 5 players shooting, thats 5x the ping spike.

I was just wondering if this was a fine method or maybe there could be better ones. It feels hacky to me even though I’ve used a similar method (where you parent a model to a folder and then animate the model on the client using child added) and it works fine.

So, is it fine to do this?

Here is a quick sample from my server code that puts it simply.

replicated_storage = game:GetService("ReplicatedStorage")
server_storage = game:GetService("ServerStorage")
players = game:GetService("Players")
http_service = game:GetService("HttpService")

server = server_storage:WaitForChild("Server")
shared_folder = replicated_storage:WaitForChild("Shared")
shared_utilities = shared_folder:WaitForChild("Utilities")

client_bridge = require(shared_utilities:WaitForChild("Client_Bridge"))

network = {
	update_viewmodel = client_bridge:get_bridge("update_viewmodel"),
	update_visuals = client_bridge:get_brdige("update_visuals"),
}

players.PlayerAdded:Connect(function(player)
	player:SetAttribute("Weapon", [[{"skin1":"Default","skin2":"Default","weapon":"Glock-17"}]])
	player:SetAttribute("Accessories", [[{"eyes":"Default","arm_clothing":"Sleeves","face":"Default","hair_style":"Bald"}]])
	network.update_viewmodel:fire_client(player, "Glock-17")
end)

network.update_visuals:connect(function(player, type_value, point)
	local weapon = http_service:JSONDecode(player:GetAttribute("Weapon"))
	if type_value == "activated" then
		local cfr = Instance.new("CFrameValue")
		cfr.Name = "update"
		cfr.Value = point 
		cfr.Parent = workspace.Client_Workspace
	end
end)
2 Likes

Help would be appreciated! Thanks!

I’m pretty sure a RemoteEvent/Function firing should not cause a ping spike.

Its just sending a message to all clients, which is what creating a CFrameValue or any other instance is doing anyway.

1 Like

Thats what I thought at first but if your firing a remote each 0.1 seconds for like 15 players then its gonna lag. Think about it, your firing a remote to the server, the server fires back to the client 15 times and it does it every 0.1 seconds… 15 times.

The reason i use cframe values is so i use a simple child added and then each client handles it

Think about it, you’re firing a remote to the server, the server then creates a CFrameValue and replicates it (fires it) to all clients, and it does it every 0.1 seconds… 15 times.

Thing is do you really need to fire a remote every 0.1 seconds? You can just send one remote event to signal the client or server that it needs to be constantly shooting.

1 Like

Your right! I didn’t think of that, im a dumba**

I’ll try it, thanks for the help!

And by the way, why aren’t you using any local variables.

It’s the way I code, are you gonna criticise me for that?

I’m just asking cause its kinda weird.

I use locals when i have to, its easier to not use locals when i dont have to.

May I ask, how would you update the position of where you are shooting, though? If you fire it once its locked the to position it was at when you started firing. I thought of using a network owner part but then exploiters can use it to make aimbot

Hmmm, I’m not really sure since it requires the client mouse position at every frame .

I think i would have to use network owner, despite it being easier for exploiters to just simply set the cframe of the part to look at anything to make aimbot

Roblox servers send data 60 times a second (usually) to all clients [see here(uncopylocked)]. This is generally ok because the data is very small in size. There’ll only really be lag if there’s a lot of data being sent.

Update it every time the client wants to shoot a bullet. In my FPS game, the client checks if the player is holding down M1 and if there’s been enough time since they’ve last fired (you can check the “last fired” part on the server), and fires a remote with the position of the mouse asking for a bullet to be shot.

I know this, I was talking about “firing the remote once” stuff.

The reason i thought it would be laggy is because so many people told me it would… I am so confused.

1 Like

It’s only wrong some of the time. In your game, check if your ping is higher with new code than with the old code. It’s up to you to see what fits your game better.

Edit: Generally, though, 0.1 seconds between events being fired isn’t harmful.

:sweat_smile: i never actually implemented the stuff with the old code, i went to the dev forum before implementing the full thing. I will try it normally with remotes.

1 Like

i tried it at a gun firing each 0.05 seconds and ping went up by 10 - 11 and i was the only player there sorry for late response

That’s half as much time as I said