--LocalScript inside StarterPlayerScripts
player = game.Players.LocalPlayer
local sp = player:WaitForChild('PlayerGui'):WaitForChild('Keybind'):WaitForChild('ImageButton')
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
if UIS:GetFocusedTextBox() == nil then
for i,v in pairs(game.Workspace.Stove["Gas"]:GetChildren()) do
local mag = (v.Parent.Union.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude
if mag <= 15 then
game.ReplicatedStorage.Stove:FireServer("Gas")
end
end
end
end
end
end)
while wait() do
for i,v in pairs(game.Workspace.Stove["Gas"]:GetChildren()) do
local mag = (v.Parent.Union.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude
local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(v.Parent.Union.Position)
if mag <= 15 then
sp.Visible = true
sp.Position = UDim2.new(0,WSP.X,0,WSP.Y)
sp.TextLabel.Text = "Open 'Stove'"
end
end
end
This is my keybind script. If you go near it, an ImageButton 'E' will appear, and if you click this, it will fire an remoteEvent. But I see a problem that is the button is blinking(because the while loop and the for loop, and it means there is a delay). If you just add one more line of a script then the blinking period(the sp.Visible = false) increases. What do I do? [There are tons of stoves in the folder]
