Hello!
I’ve been working on this door and can’t find anything that works for what I need.
I’ve search for ATLEAST 5-6 hours on raycasting and Mouse.Target but can’t find any resources that work.
Worked around 10 hours total (3 days time) trying to code the single part.
I’m basically trying to make something like this:
This is my go at it:
There’s already a ton of issues with my door, and it doesn’t include the part when the mouse is over the door.
Issue 1. Door seems to not open correctly on the backside?
“Issue” 2. I can’t figure out how to add a raycast or Mouse.Target to my script.
Here’s my code is SCS
local inputservice = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()
local PlayerGui = player:WaitForChild('PlayerGui')
local GameGUI = PlayerGui:WaitForChild('Door')
local Activ = false
local Obj = nil
local Distance = 5
inputservice.InputBegan:connect(function(Input)
if Activ and Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode == Enum.KeyCode.E then
for _,Door in pairs(workspace.Doors:GetChildren()) do
Obj.Event:FireServer()
end
end
end)
while wait() do
Activ = false
Obj = nil
GameGUI.Frame.Visible = false
for _,Door in pairs(workspace.Doors:GetChildren()) do
---I tried doing this with raycast and mouse.Target but nothing worked
--if mouse.Target and mouse.Target.Name == "Door" then
local DistanceFromCharacter = player:DistanceFromCharacter(Door.Door.Position)
if math.floor(DistanceFromCharacter) <= Distance then
GameGUI.Frame.Visible = true
Activ = true
Obj = Door
end
---end
end
end
Door model:
If we can somehow figure this out, I’d gladly make a post in community resources about it!
Thanks for your time!