Alright so I am trying to make a E to interact in my game. It’s working pretty well but i’m working with the Magnitude Checking. You know, when the player is close to a specific part, some gui pops up of nowhere.
So this is what happens with the E Icon, It does pop up when the player is close to the cash register. It positions itself to the specified part.
As you can see, the E Icon is in the wrong position, its like down right, it supposed to be position exactly to the white brick, the small brick in the cash register. It’s supposed to be position exactly where the white part is positioned and in middle.
The E Icon position uses :WorldToScreenPoint() function. E.g: workspace.CurrentCamera:WorldToScreenPoint(PartHere.Position)
The Code:
local UserInputService = game:GetService("UserInputService")
local Vehicles = workspace.Vehicles
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
while true do
script.Parent.ImageLabel.Visible = false
local Magnitude = (workspace.DonutShop.CashRegister.Rob.Position - HumanoidRootPart.Position).magnitude
if Magnitude <= 6 then
print("Enough magnitude")
script.Parent.ImageLabel.Visible = true
local D3ToD2 = workspace.CurrentCamera:WorldToScreenPoint(workspace.DonutShop.CashRegister.Rob.CFrame.Position)
script.Parent.ImageLabel.Position = UDim2.new(0,D3ToD2.X,0,D3ToD2.Y,0)
end
wait()
end
So in a while loop, it checks the magnitude if the player is in a specific range or closer. Once its closer, the E icon pops up. I do not know what could be causing this problem. Is it a bug or something just ain’t right? By the way, I got this script from DutchDeveloper, the guy makes E to interact tutorials. I’ve tried using /2 in positioning the icon, made it worse. So I decided to leave it the way it was.
If you have any ideas, suggestions, etc… Leave a reply below and I will try it.
Thanks in advance!
Michael