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

How do i fix cursor inverted position?

I am making a 2008 simulator and i've made a local part that is like green cursor block. I tried this script:

local localplayerr = game.Players.LocalPlayer

local character = localplayerr.Character or localplayerr.CharacterAdded:wait()
 
local bin = Instance.new("Message")
bin.Name = 'LocalBin'
bin.Parent = character
 
local platform = Instance.new("Part")
platform.Name = "CursorSelection"
platform.BrickColor = BrickColor.new("Lime green")
platform.Material = Enum.Material.Plastic
platform.BottomSurface = Enum.SurfaceType.Smooth
platform.TopSurface = Enum.SurfaceType.Smooth
platform.FrontSurface = Enum.SurfaceType.Smooth
platform.LeftSurface = Enum.SurfaceType.Smooth
platform.CanCollide = false
platform.Anchored = true
platform.Size = Vector3.new(2, 0.2, 2)

local msh = Instance.new("CylinderMesh")
msh.Name = "Circle"
msh.Parent = platform
 
platform.Parent = bin -- Now GREEN CIRCLE appears

wait(1)
function SetCursorPosition()
while true do
	wait()
    platform.Position = Vector3.new(localplayerr:GetMouse().X / 32, localplayerr:GetMouse().Y / 32, character.Torso.Position.Z * 32)
end
end

Spawn(SetCursorPosition)

The problem is at SetCursorPosition platform.Position...

The block is getting inverted position of cursor! Please help Thanks ~marcoantoniosantos3

1 comment

0

Are you trying to make the green part appear where the cursor is pointing?

1 answer

✓ Accepted answer

Try changing

wait(1)
function SetCursorPosition()
while true do
    wait()
    platform.Position = Vector3.new(localplayerr:GetMouse().X / 32, localplayerr:GetMouse().Y / 32, character.Torso.Position.Z * 32)
end
end

Spawn(SetCursorPosition)

to this:

local mouse = localplayerr:GetMouse()

Game:GetService("UserInputService").InputChanged:connect(function(inst)
	platform.Position = mouse.Hit.p + Vector3.new(0, .1)
end)

1 comment

0

Thanks! It's working now!

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