#fps help
106 messages · Page 1 of 1 (latest)
i don’t where to start scripting it i’m a newbie with roblox studio
is gun system coded.
it’s just the model if that answers your question
oh.
personally coding whole gun to work isn't easiest just to write down of bat
you need anims etc
Coding a gun is pretty challenging if it's your first time, but you will learn a LOT about how Roblox works if you can get it working
** You are now Level 3! **
I remember my first attempt at a realistic fps game with recoil. The recoil system alone took me like a week because I was trying to simulate recoil like real life with physics equations that I looked up online, and getting them to work properly was a pain
And then there's the whole CFrame stuff you have to do if you want bullets to have drop instead of being an instant hit-scan bullet. And you need to fire remote events so that the server can replicate bullets to other clients and also damage them if they are hit
teaches u view models etc
but not basics
Oh yeah that too
I struggled so much with viewmodels lol
going of one fundemental isn't good way to construct code
you need to understand explorer, properties how everything works
I learned that the viewmodel has to be anchored on the client but not the server, or it keeps falling even though it looks like it's not. super weird
might learn it from gun system but still takes testing and learning
my best tip to anyone learning is
Start smol
not exactly
Make a plan first?
is to learn function, if they don't understand it then, test and test until you know how works and you could rewrite function yourself.
oh yeah true
if u wanna learn fps learn explorer. learn raycasting
etc
particle emitters smoke effects etc
test stuff
if you go too deep, you start to learn some horrible truths about the roblox game engine (low tick rate, wait() is actually not very accurate, etc)
The thing that makes me the angriest tho is that there is no high-frequency game loop to handle sounds. Most video games have a separate thread for sounds that runs at like 2000 fps or higher so that sounds can be played at accurate times. If your gun sounds are running in a 60 fps loop, you'll hear some slight stuttering since the frame timing isn't always the same. It bothers me so much. I can't unhear it now. Every fps game on roblox has this problem
oh yeah and don't believe while loops don't run code below until its finished. I did coding for ages thinking loop had to end for it to do code at the end of it but no dead wrong.
e.g
local loop = false
while 1==1 do
wait()
end
loop = true
the end part will still run even when looping
hmm interesting
i was making injurySystem
Wait what
figured out recently
are you sure the while loop isn't inside an event or something?
nah
ill send u my code example
In my experience, the while loop will halt everything else from running unless it's inside a function connected to an event, where it runs on a separate thread everytime the event is called. That messed up my gun code so badly smh. If you clicked really fast, you could basically make the gun fire multiple bullets at once and do super damage lol
i had to put if cause code at end was still running
while wait(1) do
if bleedT.Value <= 0 then
bleedDMG.Value = false
bleed:Destroy()
break
end
bleedT.Value = bleedT.Value - 1
end
even tho it was out of loop
wow that's strange
could been linked to the delay though
idk there's some wack stuff about lua i probably don't understand lol
verymuch same here
task.wait is the fixed wait
I was so happy when I discovered that lol
Originally, I was using my own custom wait function, but it felt kind of annoying to use
WAIT HOLY S wait in inaccurate?
Good server verification is also difficult in Roblox because no easy way to do rollback (unmeasurable delays)
It resumes at like 30Hz or something aka not ever frame
Yeah because the internal clock for wait() only checks how much time has passed every other frame...so it checks every like 0.32 seconds how much time has passed. If you want to measure time intervals less than 0.32 seconds, wait() won't help you
task.wait checks to resume every heartbeat
With an fps unlocker, wait() works really well, but most people don't use an fps unlocker? idk
task.wait is affected by fps unlockers as well
Oh yeah another important thing about fps games is to be very careful about how many remote events you fire. If you fire a remote event every single time the gun shoots, it's going to be super laggy for you because roblox can't send remote events at a rate faster than like 20 times per second, so it will bunch up remote events and then fire them all at once every 20th of a second, leading your gun to sound sputtery
ty you guys
helped me shit ton i didn't know this for years
Best to send one remote to let the serve know you have started firing, then have the server loop the bullets. Then send an event when you stop shooting so that the server will stop making bullets come out
saves a ton on network bandwidth and reduces lag
Someone said remotes are fired at end of every frame I've heard
But I agree with your point
If someone has an automatic weapon you should accumulate the shots into one message to send
And you can hide the fact that shots are sent multiple at a time by making the server spread out the shots over time
like if your gun shoots 60 times per second but you can only send a remote event every 1/20th of a second, that means you have to send 3 shots to the server every 1/20th of a second. But the server runs at 60 fps, so it can take those three shots and make each one appear 1/60th of a second after the other, so it doesn't seem like you're shooting 3 shots at the same time every 1/20th of a second. I guess that technically means that there will always be a delay of about 1/20 seconds between you firing and the first bullet that comes out on the server, but that's the best you can do when roblox doesn't have a high tick rate for remote events 😩
And that's why I kinda hate roblox sometimes. 1/20 of a second is 0.05 seconds, which is about 3 frames if you're running at 60 fps. A lot can happen in 3 frames, especially in a fast-paced shooter, so you have to account for stuff like someone running behind a wall but on the screen of the person shooting, they haven't fully gone behind the wall yet. There's always a 0.05 second delay for everything you do in roblox. So if you start moving, it will take at least 0.05 seconds before someone sees you start to move. I guess this is where the "hit registration" or "lag compensation" mechanic in fps games comes in. Unfortunately, i'm not sure what the best way to handle this is because someone's always going to complain no matter what you do lol
It sucks when you're shooting at someone but your gun does no damage because the server is like "well, they were behind a wall on THEIR screen, so your bullets don't count!", but it also sucks when you are ducking behind a wall and die behind cover because the server is like "well, you weren't behind the wall on THEIR screen, so their hits still count!"
Do you have a source on the update rate for remotes being 1/20 of a sec
I guess you could do some kind of balance where you take the point of view of the person shooting, the point of view of the person being shot, and the point of view of the server and kind of average out everything to determine what to do?
** You are now Level 4! **
unfortunately, the information was on the Developer Hub, but that got deleted 😂
I guess you can try it yourself by sending a remote event 60 times per second to the server, and on the server keep track of how much time passes between each event. You should see something like 1/20th of a second passes and then a burst of 3 events arrive at the same time, then another pause of 1/20th of a second
Or maybe they changed the rate? idk i haven't coded on roblox in a while lol
Oh yea Idk why I thought it was every frame this image cleary says "does not happen every frame" lol
For send jobs
I guess receive jobs happens every frame unless it just doesn't say it doesn't for some reason
This image has been around for a while they gotta add the new runservice events and stuff but here
Oh sick!
the new documentation is really nice
Yeah, it seems like remote events can fire up to 60 times per second, but it's not guaranteed
Interestingly, if you use the roblox fps unlocker mod thingy, you can fire remotes as fast as you want lmao
Yee
But it only works on the clients using the fps unlocker, so I guess you can't always rely on that? Plus sending that many remotes still impacts performance
idk how that even works....sounds like a hack lol