So I’m making a remake/rebuild of an old paintball game, and I found a good model of a paintball gun that still works.
Now everything seems to be going well… except that it keeps shooting to my right side no matter where I’m facing. I’m not sure how to make it just shooting ahead of them (maybe not following their mouse, but mostly only stay in one line at best?)
Also, oddly it also painted some of the blocks (which I didn’t want it to do that, I just want it to only ‘paint’ the players if they get shot by another player’s paintballs).
I tried looking up how to fix this problem, but no lucks.
I have no real solution to this, however, tools like this paintball gun could be broken because Roblox unfortunately doesn’t support them anymore. Example like Roblox skateboards and how Roblox broke them. If there is no solution then the best way is just to make your own paintball gun.
You could try changing the direction of the force to either force.force = Vector3.new(90 * missile:GetMass(),0,0) or force.force = Vector3.new(0,0,90 * missile:GetMass()).
Yeah as @LukeWasAlreadyTaken mentioned the issue is due to the FE filtering update particularly this property concerned with the targeting portion of the script.
This property is a client only property and assuming the script is a server script this target point will only be (0,0,0).
To fix this you have to find a way to transmit where the mouse is pointing perhaps via mouse.Hit or UserInput services in a local script then send it over to this server script via a client to server remote event.
I tried the first one, it just gave the same result, altho it now kinda shoot more straight (but still stuck to the same side from where I was shooting before).
Perhaps these little snippets from my gun code will show what I eventually ended up doing…
== LocalScript (Client Script)
ClientControl = Remotes:WaitForChild("ClientControl")
function OnClientInvoke(mode, value)
if mode == "MouseData" then
return {Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target}
end
end
ClientControl.OnClientInvoke = OnClientInvoke
== Script (Server Script)
function onActivated()
if enabled then
enabled = false
local MouseData = InvokeClient("MouseData")
if Tool.Parent and Tool.Parent:FindFirstChild("Humanoid") and Tool.Parent:FindFirstChild("Head") and MouseData and MouseData.Position then
local character = Tool.Parent
local humanoid = character:FindFirstChild("Humanoid")
local head = character:FindFirstChild("Head")
local targetPos = MouseData.Position --humanoid.TargetPoint
--print(targetPos)
local lookAt = (targetPos - head.Position).unit
gunUp()
fire(lookAt)
wait(0.1)
gunOut()
wait(reloadRate)
reloadCount = reloadCount + 1
if reloadCount > 3 then
Tool.Handle.Reload:Play()
reloader()
reloadCount = 0
end
end
enabled = true
end
end
As for the bullets painting the objects instead of only players, its an intended behaviour. If you wish to remove it, add a check to the hit script that handles colouring parts to see if the hit.Parent has a humanoid.
Also, read this please: The enabling of FE caused another issue that is only apparent once you attempt to use the gun in normal gameplay. The projectiles are now purely handled by the server and not by the player as they once were when paintball guns were made in 2007. This means that the projectiles are very unsmooth and highly prone to server lag and travelling speed isues. You are highly recommended to make the projectiles localsided to prevent this, through the use of a localscript that creates the projectiles and uses a FireAllClients to show the players the projectile.