Well, I’m wanting to make a system that opens the door based on the direction of the character. I’ve already done the part of detecting the character, but I’m new to RayCast, so I don’t know if it’s right.
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Players = game:GetService("Players")
local TS = game:GetService("TweenService");
local frame = script.Parent:WaitForChild("Frame");
local proximity = frame:WaitForChild("ProximityPrompt");
local LeftD = script.Parent:WaitForChild("Left_Door");
local RightD = script.Parent:WaitForChild("Right_Door");
local enabled = true;
proximity.Triggered:Connect(function(plr)
local character = workspace[plr.Name]
local Direction = (frame.CFrame * CFrame.Angles(0, math.rad(-90), 0)).LookVector--It rotates it 90° because I modeled the door wrong, but that's how it turns out
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {character}
local raycastResult = workspace:Raycast(frame.Position, Direction * 100, raycastParams) -- Rayo de 10 unidades de longitud
if raycastResult and raycastResult.Instance.Parent == character then -- Donde 'object' es el objeto que quieres verificar
print("yes")
else
print("no")
end
if enabled then
end
end)