02 | player = game.Players.LocalPlayer |
04 | local sp = player:WaitForChild( 'PlayerGui' ):WaitForChild( 'Keybind' ):WaitForChild( 'ImageButton' ) |
06 | local UIS = game:GetService( "UserInputService" ) |
08 | UIS.InputBegan:Connect( function (input,gameProcessed) |
10 | if input.UserInputType = = Enum.UserInputType.Keyboard then |
11 | if input.KeyCode = = Enum.KeyCode.E then |
12 | if UIS:GetFocusedTextBox() = = nil then |
14 | for i,v in pairs (game.Workspace.Stove [ "Gas" ] :GetChildren()) do |
16 | local mag = (v.Parent.Union.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude |
20 | game.ReplicatedStorage.Stove:FireServer( "Gas" ) |
31 | for i,v in pairs (game.Workspace.Stove [ "Gas" ] :GetChildren()) do |
32 | local mag = (v.Parent.Union.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude |
33 | local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(v.Parent.Union.Position) |
38 | sp.Position = UDim 2. new( 0 ,WSP.X, 0 ,WSP.Y) |
40 | sp.TextLabel.Text = "Open 'Stove'" |
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]