What is wrong with my code?

I’ve been trying do a smooth system like this:


but always do that:
before i hover the part:
after:

he doens’t go to the correct position.

also, i’m just beginner, maybe this solve are more simple that i think.
i’m gratefully for anyone who help me <3
thanks.


SCRIPT:

local mouse = game.Players.LocalPlayer:GetMouse()
local part = workspace.Part
game:GetService("RunService").RenderStepped:Connect(function()
local test = script.Parent:WaitForChild('Info').TextLabel

	if mouse.target.CastShadow == false then
		test.HoverTextGui.ItemName.Text = mouse.target.Name
		script.Parent.Crosshair.VisibleCrosshairs:TweenPosition(UDim2.new(mouse.target.Position), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, .3)
		script.Parent.Crosshair.VisibleCrosshairs.Default:TweenSize(UDim2.new(0, 7,0, 7), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, .3)
		test:TweenPosition(UDim2.new(0.367, 0,0, 499), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, .3)
		
else
		script.Parent.Crosshair.VisibleCrosshairs:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, .3)
		script.Parent.Crosshair.VisibleCrosshairs.Default:TweenSize(UDim2.new(0, 5,0, 5), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, .3)
			test:TweenPosition(UDim2.new(0.367, 0,2, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, .3)
			end
end)

2 Likes

Can you explain what ‘system’ you’re trying?

Since there are many different systems in the video that you showed

1 Like

You’re trying to set the position of the cross-air to a UDim2 value which is set to be the position of the part which is a Vector3 value, not a UDim2 value. That’s why your cross-air is going to that position on the screen.

2 Likes

so i need to change for vector?

the crosshair go to the part with tweenservice

You want to make your screen shake smoothly? You need to mess around with CameraOffset on the Camera object I believe;

Nope, i already made that, i’m trying to do the following:
when the mouse passes over the part, the crosshair will go to the middle of the part to find the one the user is selecting.

warning: after that answer above, there is an answer in portuguese for a better understanding.

Opa, fala ai. Eu estou tentando fazer o seguinte:
quando o mouse passar por cima da parte, o crosshair vai ir para o meio da parte para localizar a qual o usuario está a selecionar.

thank you <3

You don’t need to answer in portuguese, I understand English really well.

Anyways, I believe there’s a thing on Mouse which allows you to get the position and everything from a Vector3 to UDIM2, but I don’t remember which one was it. I’m gonna try to find it here.

its because i dont understand so well english, so maybe can have errors, lol.
ok, maybe this can help, thank you.

Eu falaria pra tu dar uma esperada ksks, tem que mexer com CFrame.LookAt, com Raycasting e é meio difícil de mexer com essas coisas sem saber, tem vídeos nessas coisas pelo menos em inglês :P

mas então esse é o unico metodo possivel pra fazer o que eu quero? não tem algum conversor de Vector3 to udim2 nn? raycast é uma bosta, e não consigo entender muito bem.

Então, deve ter alguma coisa com o Player:GetMouse() ou com UserInputService; mas eu não sei o que é, tenta ver se tu encontra alguma coisa no DevForum;

o pior que ontem eu passei horas tentando achar algo que me ajude, eu não consegui achar nada, nada que pelo menos me ajude um pouco, pelo jeito é apenas possivel pelo raycast. é meio duvidoso isso. a comunidade brasileira é bem pequena em LUA, eu nunca consegui achar um video de raycast brasileiro no youtube, o jeito é ver um video ingles e tentar aprender, pois nunca consegui aprender algo vendo algum video. é dificil.

Então, to pensando aqui, pra isso da pra você tentar usando um Billboard GUI, que passa pelas parts e colocar essa Billboard gui dentro da part, e tal, esse é um jeito, é o mais simples pelo menos. Se não isso, eu não consigo te ajudar com mais nada, eu não sei muito sobre essa coisas também.

English;

We talked about how he would need to mess around with Raycasting and CFrame and some converting to allow him to do that, he asked it there’s another way, there could be something that I don’t know about in UserInputService; He can use a Billboard GUI to do that.

I will test that, maybe can help me.