Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making mousehit more accurate?

Asked by 5 years ago

Ive got an issue with things not really moving towards the mouse very accurately. They will move in the general direction but not where the mouse is aiming, forcing players to aim really low. Is there a better way to send something towards where the player is aiming?

local script:


function Keys(key) local Key = key:lower() if key == "z" then script.ZMove:FireServer(mouse.Hit) end if key == "x" then script.XMove:FireServer(mouse.Hit) end if key == "c" then script.CMove:FireServer(mouse.Hit) end if key == "b" then script.BMove:FireServer(mouse.Hit) end if key == "v" then script.VMove:FireServer(mouse.Hit) end end

(this isnt the whole script but it's the relevant parts)

server script:

            local Lance1 = game.ReplicatedStorage.Fruits.FlameStuff.FireLance:Clone()
            Lance1.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(1,0,0)
            Lance1.Parent = Player.Character.AttackFolder
            local Lance2 = game.ReplicatedStorage.Fruits.FlameStuff.FireLance2:Clone()
            Lance2.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(-1,0,0)
            Lance2.Parent = Player.Character.AttackFolder
            Lance1.MeleeDamage.Disabled = false
            Lance2.MeleeDamage.Disabled = false
            local BV = Instance.new("BodyVelocity")
            BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
            BV.Velocity = mousehit.LookVector*80
            BV.Parent = Lance1
            local BV2 = BV:Clone()
            BV2.Parent = Lance2

(again not the whole script, but the relevant parts)

Thanks for reading

0
also yes ik KeyDown is deprecated. I'm changing that soon techlevel89 9 — 5y
0
oh by the way you dont have to do 5 conditionals for local script you can just say if key == "z" or "x" or "c" or "b" or "v" then fire server RetroGalacticGamer 331 — 5y
0
no, you have to restate the entire if statement. doing what you said will check if the string "x" is truthy, not if it satisfies the previous conditions Gey4Jesus69 2705 — 5y

Answer this question