Ad
Log in to vote
0

If I look at the door and press the letter 'E' something happens! Can anyone help me?

Asked by 6 days ago

Without proximity prompt door system like Granny!

1 answer

Log in to vote
0
Answered by 6 days ago

You can put like a BoolValue in your doors and then make a localscript.

In that script you can use UserInputService, use Mouse.Target to check if the player's mouse is pointing over a door then use DistanceFromCharacter to check the player's distance from the door.

Something like this:

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input, gameProcessedEvent)
    if gameProcessedEvent then return end

    if input.KeyCode == Enum.KeyCode.E then
        if mouse.Target then
             if mouse.Target:FindFirstAncestorOfClass("Model"):FindFirstChild("Door") then
                local distance = player:DistanceFromCharacter(mouse.Target.Position)
                if distance < 30 then
                    -- Open the door using TweenService
                end
            end
        end
    end
end)
Ad

Answer this question