So I wanted to make it so that when a player is 15 studs close to the part I have set below and they pressed the E button then the frame would become visible. But for some reason it doesn’t seem to work,I’ve tried messing around with the code but nothing seems to work. Maybe I’m missing something simple.
The Code:
–Variables
local player = game.Players.LocalPlayer
local part = workspace.Part
local billboard = part.BillboardGui
local frame = game.StarterGui.ScreenGui.Frame
local maxDist = 15
local UIS = game:GetService(“UserInputService”)
while wait() do
if (part.Position - player.Character.HumanoidRootPart.Position).Magnitude <= maxDist then
billboard.Enabled = true
else
billboard.Enabled = false
end
end
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
if billboard.Enabled == true then
frame.Visible = not frame.Visible
end
end
end
end)