In front of the SurfaceGui is a Screen that blocks the player from being able to click the buttons. Is there a way to “ignore” that screen so the players can click the buttons?
The ignore folder is for the TargetFilter so only the Computer can be seen through the Mouse, but i’m still not sure how to go from there
I don’t think there is a direct way to do this, but you can make it so when you are interacting the computer, it deletes temporarily the parts blocking it, so the player can click on those programs.
You can also check where the mouse has clicked on, then raycast or convert those coordinates to a world position and check if they are over that part, if they are, then do stuff.
I already did the raycast part, can you tell me how to convert it to WorldPosition and check? Even documents or other posts can help.
My current code is
Mouse.Button1Down:Connect(function()
if Mouse.Target then
if Mouse.Target == Computer then
local ray = Mouse.UnitRay
ray = Ray.new(ray.Origin, ray.Direction)
end
end
end)
You can use workspace:Raycast() which accepts RayCastParams.
Example:
local params = RayCastParams.new()
params.FilterType = Enum.FilterType.Exclude
params.FilterDescendantsInstances = -- put a table of the parts you want it to ignore
And then you can implement this into your current code:
ray = workspace:Raycast(ray.Origin, ray.Direction, params)
If you want to convert mouse position into world position than you can use workspace.CurrentCamera:ViewportPointToRay()
It’s basically mouse.Hit.p but better.
How to implement it:
local mousePos = UserInputService:GetMouseLocation() -- your gonna have to make a variable that gets user input service
local worldMousePos = workspace.CurrentCamera:ViewportPointToRay(mousePos.X, mousePos.Y)