right now I’m working on an FPS gun system (very original1!!) but I’m wondering how I should handle firing of the weapon?
I was originally thinking that I could just check for "InputHeld" with UIS and just run a gunfire event, and then the server would constantly fire depending on the gun’s type.
but now that I think about it, I don’t think this’ll work, because I would have to constantly some how get where the camera is looking with only one input
I have thought of just spam firing the gunfire event on the client, and then the server could handle it. but how would I accommodate for the fire rate? and the gun firing type? I don’t know if I’m missing something obvious or doing this very wrong but I’d still like some help
NOTE: my gun stats are handled in a module script inside of serverstorage. i would like to keep it inside of serverstorage for the sake of security and other things, but this makes getting the stats impossible on the client
local firerate = 10 -- Bullets Per Second
local mouseheld = false
coroutine.wrap(function()
while mouseheld do
task.wait(1/firerate)
print("shoot!")
end
end)()
mouse.Button1Down:Connect(function()
mouseheld = true
end)
mouse.Button1Up:Connect(function()
mouseheld = false
end)
It’s okay to use modules and put it in ReplicatedStorage or basically anywhere else… because i believe when you require() a module script, it’ll be saved in it’s current state which means any future change done SHOULDN’T affect it. BUT exploiters can use getgc() which is REALLY complicated to get rid off
keep in mind getgc() will always be able to change tables inside ANY localscript so, if you theoratically put it (the settings module) in serverstorage and moved it to a localscript (through event communications) it will still be affected
If it’s a modulescript then yes, WHEREVER you put it won’t stop exploiters from changing it using getgc() which like I said… returns EVERY SINGLE table in the game (including Enum even)
And as for effectiveness, i would say using coroutine.wrap (the method i showed) would be efficient since Gun Systems like ACS and FE Gun Kit used it