Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How could I make mouse.Hit more precise?

I have always noticed that the mouse.Hit variable can be very off, is there a way to make it more precise? If you want to test it put this in a local script in StarterPlayerScripts.

mouse = game.Players.LocalPlayer:GetMouse()
debounce = true

function BlackHole(pos)
	if debounce == true then debounce = false
		local character = game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)
		local torso = character:WaitForChild("Torso")
		local bullet = Instance.new("Part", game.Workspace.MagicContainer)
		local sphere = Instance.new("SelectionSphere", bullet)
		sphere.Adornee = bullet
		sphere.Color3 = Color3.fromRGB(12,4,4)
		bullet.Size = Vector3.new(3,3,3)
		bullet.Shape = "Ball"
		bullet.BrickColor = BrickColor.Black()
		bullet.TopSurface = "Smooth"
		bullet.BottomSurface = "Smooth"
		bullet.Anchored = true
		bullet.CanCollide = false
		bullet.CFrame = torso.CFrame * CFrame.new(0,(game.Players.LocalPlayer.Stats.Level.Value/2)+5,0)
		torso.Anchored = true
			for i = 1, (game.Players.LocalPlayer.Stats.Level.Value + 4) * 10 do
				bullet.Size = bullet.Size + Vector3.new(0.1,0.1,0.1)
				wait(10/(game.Players.LocalPlayer.Stats.Level.Value+1)/150)
			end
		local velocity = Instance.new("BodyVelocity",bullet)
		velocity.Velocity = pos.p --the problem
		velocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		bullet.Anchored = false
		torso.Anchored = false
		game:GetService("Debris"):AddItem(bullet, 3)
		wait(2)
		debounce = true
	end
end

mouse.Button1Down:connect(function()
     BlackHole(mouse.Hit)
end)

If you don't know what I'm talking about visit http://wiki.roblox.com/index.php?title=API:Class/Mouse/Hit

8 comments

0

What do you mean by "very off"??

0

I'm using it in my laser tool and the laser doesnt shoot exactly where I click

0

Yes, but i'm not quite sure it will help

0

Tried it, didn't work

0

Can you post the script

0

Yes

0

mouse.Target

1 answer

Im not sure what you mean by "Very off", as this is very broad. But, I do have a guess.

Heres a code to get the CFrame your mouse is pointing to. I hope this helps!

Wiki:

http://wiki.roblox.com/index.php?title=API:Class/Mouse http://wiki.roblox.com/index.php?title=API:Class/Mouse/Target http://wiki.roblox.com/index.php?title=API:Class/Mouse/Move

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.Move:connect(function()
	local Target = Mouse.Target
	if Target ~= nil then
		print(Target.Name)
		print(Target.CFrame)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.