I’m currently using :ApplyImpulse() to fire a paintball from a gun, but the paintball doesn’t fly very smoothly. Is there anything else that could produce the same effect but that’s less glitchy?
Can you describe the current way the paintball flies, and how you want it to fly? Images/Videos would be preferable.
I have an idea of what it is. Read up on Network Ownership. Network Ownership | Roblox Creator Documentation
Basically, this doesn’t have anything to do with :ApplyImpuse().
It has to do with Roblox changing the paintball’s network owner in the middle of its flight path. If you read the article I sent, you can find an example of how you could fix this. What I would do is set the network ownership to the person who shot the paintball so there isn’t a visual delay for them.
Hmm ok, that sounds right but whenever I tested it the paintball just fell to the ground and :ApplyImpulse() didn’t do anything. Here’s my script and a video:
local ts = game:GetService("TweenService")
local debris = game:GetService("Debris")
game.ReplicatedStorage.FireEvent.OnServerEvent:Connect(function(plr,pos)
local char = plr.Character
local sniper = char:FindFirstChild("Sniper")
local paintball = game.ServerStorage.Paintball:Clone()
paintball.Parent = game.Workspace
paintball.CFrame = CFrame.new(sniper.ShootPart.CFrame.Position, pos)
paintball:SetNetworkOwner(plr)
paintball:ApplyImpulse(paintball.CFrame.LookVector * 500)
end)
And here’s what happens:
I would try setting the paintballs velocity manually instead of using :ApplyImpulse()
That way, you can verify the ball is actually going the correct velocity
So how would I set the paintball’s velocity manually?
This event is not safe, an exploiter could easily spam this and cause lag by creating objects.
Ok…
- This isn’t supposed to be a public game, it’s just a game for me to play around with my friend in, there won’t be any exploiters.
- The code isn’t done yet.
That wasn’t what I asked for help with bro.
I suggest you use BodyVelocity, yes I know they are deprecated but they don’t require attachments unlike other movers(plus they are easier to set up), you can use MaxForce and Debris to make it last for a certain amount of time.
Yeah I did use Body Velocity before, but if I use :ApplyImpulse() then gravity will take care of the bullet drop for me. And Body Velocity has the same weird glitchy thing were the bullet lags too, so I still need help.
I think it does have something to do with NetworkOwnership but like I said, the paintball just falls to the ground when I try that.
local __SPEED = Instance.new("BodyVelocity")
__SPEED.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
__SPEED.Velocity = (sniper.ShootPart.CFrame.LookVector + Vector3.new(0,0,0)) * 90
__SPEED.Parent = paintball
You can try this snippet I have for my projectiles.
No. Use FastCast instead:
You will run into every single problem imaginable if you rely on Roblox physics for this.
Brother are you seriously suggesting FastCast right now. This module is super laggy most of the time.
I understand the game is only for him and his friend, but at the LEAST let him know not to use it with bigger games.
It’s not. I’ve gotten it working on a gun, you just need it on the client.
Are you telling me that every game that uses FE gun kit is not a good game?
Yeah, I try and only use my own scripts though, I’m not going to learn if I just copy and paste.
So what would you recommend I do?
local power = 100
local function FireBullet(gun)
local bullet -- Create bullet here
bullet.AssemblyLinearVelocity = gun.Handle.LookVector * power
end
This should set the velocity of the bullet in the direction the gun is pointed.
Whether this is the best way to do it or not, I don’t knw, but it works. Thank you!