Hello, I am working on make a script that detects when the player clicks the E key it will do a function. In the script I reference to a image Label inside of the billboard Gui, and inside of that there is a Value, when I remove the value the script works fine, but if I add it back its say that the Image Label cant be found, even though its still there
A image of the Gui:
My Script:
local UIS = game:GetService("UserInputService")
local KeyDown = false
local prog = script.Parent.Button-- This is not found once the value is put into the Gui.Progress -- Here is where I reference to the Image Label
local prompt = script.Parent
function Hide()
prompt.Enabled = false
prompt.Adornee = nil
end
function E()
local Inc = 1/(script.Parent.ClosestPart.Value.RemoteEvent.Time.Value/0.2)
if script.Parent.ClosestPart.Value.RemoteEvent.Time.Value <= 1 then
script.Parent.ClosestPart.Value.RemoteEvent:FireServer()
script.Parent.Enabled = false
Hide()
prog.YSize -- The value.Value = 0
KeyDown = false
elseif script.Parent.ClosestPart.Value.RemoteEvent.Time.Value > 1 then
wait()
repeat
if KeyDown == true and script.Parent.Adornee ~= nil then
if prog.YSize.Value < 1 then --Number value is size of the moving E part
prog.YSize.Value = prog.YSize.Value + Inc
prog:TweenSize((prog.Size + UDim2.new(0,0,Inc,0)), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear,0.2, false,nil)
else
wait()
script.Parent.ClosestPart.Value.RemoteEvent:FireServer()
prog.YSize.Value = 0
Hide()
KeyDown = false
end
elseif KeyDown == false and script.Parent.Adornee ~= nil then
prog.YSize.Value = 0
prog.Size = UDim2.new(1,0,0,0)
elseif KeyDown == true and script.Parent.Adornee == nil then
prog.YSize.Value = 0
prog.Size = UDim2.new(1,0,0,0)
KeyDown = false
end
wait(0.2)
until KeyDown == false
prog.YSize.Value = 0
prog.Size = UDim2.new(1,0,0,0)
end
end
UIS.InputBegan:Connect(function(Key, Gameprocess)
if Key.KeyCode == Enum.KeyCode.E and not Gameprocess then
KeyDown = true
prompt.Button.Progress.Visible = true
prompt.Button:TweenSizeAndPosition(UDim2.new(0.650, 0,0.650, 0), UDim2.new(0.176, 0,0.174, 0), "Out","Quad",.2,true)
prog.YSize.Value = 0
prog.Size = UDim2.new(1,0,0,0)
E()
end
end)
UIS.InputEnded:Connect(function(Key, Gameprocess)
if Key.KeyCode == Enum.KeyCode.E and not Gameprocess then
KeyDown = false
prompt.Button.Progress.Visible = false
prompt.Button:TweenSizeAndPosition(UDim2.new(1,0,1,0), UDim2.new(0, 0, 0, 0), "Out","Quad",.2,true)
E()
end
end)
UIS.InputBegan:Connect(function(Key, Gameprocess)
if Key.KeyCode == Enum.KeyCode.ButtonX and not Gameprocess then
KeyDown = true
prompt.Button.Progress.Visible = true
prompt.Button:TweenSizeAndPosition(UDim2.new(0.650, 0,0.650, 0), UDim2.new(0.176, 0,0.174, 0), "Out","Quad",.2,true)
prog.YSize.Value = 0
prog.Size = UDim2.new(1,0,0,0)
E()
end
end)
UIS.InputEnded:Connect(function(Key, Gameprocess)
if Key.KeyCode == Enum.KeyCode.ButtonX and not Gameprocess then
KeyDown = false
prompt.Button.Progress.Visible = false
prompt.Button:TweenSizeAndPosition(UDim2.new(1,0,1,0), UDim2.new(0, 0, 0, 0), "Out","Quad",.2,true)
E()
end
end)
script.Parent.Button.MobileButton.MouseButton1Down:Connect(function()
KeyDown = true
prompt.Button.Progress.Visible = true
prompt.Button:TweenSizeAndPosition(UDim2.new(0.650, 0,0.650, 0), UDim2.new(0.176, 0,0.174, 0), "Out","Quad",.2,true)
prog.YSize.Value = 0
prog.Size = UDim2.new(1,0,0,0)
E()
end)
script.Parent.Button.MobileButton.MouseButton1Up:Connect(function()
KeyDown = false
prompt.Button.Progress.Visible = false
prompt.Button:TweenSizeAndPosition(UDim2.new(1,0,1,0), UDim2.new(0, 0, 0, 0), "Out","Quad",.2,true)
E()
end)
````