Re-creating air x interactive cockpits

This is how the buttons work:
https://gyazo.com/2c4a91650eda33e5e0a6a12401a5d6ac
I have tried everything from billboard guis,click detectors and ray casting and mouse.hit and all of these dont work when the plane is moving fast due to the way roblox renders stuff at high speeds… Does anyone have an idea how I could make something like this?

Hey KingAviationer,

Have you tried Mouse.Target? This allows you to hover your mouse over a part and detects the part you’re pointing at. With this you might be able to detect that you’re mouse is over it, display a UI pop up and do the mechanics from there?

2 Likes

Hello,so I have made this quick code to check if it will work at high speeds,and it does.now do you have an example for an MouseButton1Click where it checks if the mouse.Target has a child(RemoteEvent) that is named a specific name(in this case battery) and it fires it

local Players = game:GetService(“Players”)

local player = Players.LocalPlayer

local mouse = player:GetMouse()

while true do wait()

game.Workspace.SelectionBox.Adornee = mouse.Target

end

Hey,

So you’d probably do something like

local RunService = game:GetService("RunService")

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

local CurrentlySelected = nil

Mouse.Button1Down:Connect(function()
if CurrentlySelected ~= nil then
-- I'm still hovering over a button
-- fire remote event
end
end)

RunService.RenderStepped:Connect(function()
if Mouse.Target.Name == "Thing You want to select" then
if CurrentlySelected ~= Mouse.Target then
-- DELETE OLD PROMPT
CurrentlySelected = Mouse.Target
-- ADD NEW PROMPT
else
CurrentlySelected = Mouse.Target
-- ADD NEW PROMPT
end
end
end)
1 Like

Where can I add the Mouse.Button1Down:Connect(function()? because I added it to the add new prompt part but it still recognizes a click after the mouse is no longer on the target

You wouldn’t add a button1down inside the – add new prompt part because you’d be using up more resources than you need.

1 Like

where do I add the mouse.button1down then?(sorry I am pretty clueless about this I am no scripter haha)

Well where it says

-- ADD NEW PROMPT

I thought you had a GUI that you wanted to show visually that it was detected. You can just put the Button1Down event above the renderstepped like i wrote above.

1 Like

Thank you very much :heart: :heart: