I'm trying to make my paintball gun shoot to the players mouse position but it shoots the underneath the player and doesn't go to the mouse. How do i fix this?
The script is in a GUI and I want to keep it like that.
Here is my whole script :
colors = {45, 119, 21, 24, 23, 105, 104} function fire(v) print'shot' local vCharacter = game.Players.LocalPlayer.Character local vPlayer = game.Players:playerFromCharacter(vCharacter) local missile = Instance.new("Part") local spawnPos = vCharacter.PrimaryPart.Position spawnPos = spawnPos + (v * 8) missile.Position = spawnPos missile.Size = Vector3.new(1,1,1) missile.Velocity = v * 100 missile.BrickColor = BrickColor.new(colors[math.random(1, #colors)]) missile.Shape = 0 missile.BottomSurface = 0 missile.TopSurface = 0 missile.Name = "Paintball" missile.Elasticity = 0 missile.Reflectance = 0 missile.Friction = .9 local force = Instance.new("BodyForce") force.force = Vector3.new(0,90,0) force.Parent = missile --Tool.BrickCleanup:clone().Parent = missile local new_script = script.Parent.SnowGun:clone() new_script.Disabled = false new_script.Parent = missile local creator_tag = Instance.new("ObjectValue") creator_tag.Value = vPlayer creator_tag.Name = "creator" creator_tag.Parent = missile missile.Parent = game.Workspace end function activate() local character = game.Players.LocalPlayer.Character local humanoid = character.Humanoid if humanoid == nil then print("Humanoid not found") return end local targetPos = humanoid.TargetPoint local lookAt = (targetPos - character.Head.Position).unit fire(lookAt) wait(.5) end mouse = game.Players.LocalPlayer:GetMouse() mouse.Button1Down:connect(activate)
local force = Instance.new("BodyForce") force.force = Vector3.new(0,90,0) force.Parent = missile
Your meant to write the scripts yourself, but anyhow. Its to do with the force in each bullet. The force was written to be 90, so its quite small. You could change it to purhaps 200 to 500. Over that amount would send them flying out to fast to be seen well. Remember that you can edit the script as many times as needed to get it perfect.
local force = Instance.new("BodyForce") force.force = Vector3.new(0,350,0) force.Parent = missile
--Thumbs this up if it helped. Click accept answer to give me recognition