Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI Problem (Visible is not a valid member of ScreenGui?) [ContextActionService]

Asked by 7 years ago

Everything else works, but the GUI won't show up. This script is located in a LocalScript. And what's inside is a TextButton that whenever pressed, it will play an animation. This animation is the tool.GripPos...

Could be minor mistakes, but this LocalScript's just not working lol.

local tool =  script.Parent.Parent.Parent
local gui = script.Parent.Parent
local button = script.Parent
local Debounce = true
local Active = false

local CoolDown = 0.01 -- Change to what you want
local function Start()
tool.rMovement.Disabled=true
    tool.lMovement.Disabled=true
    tool.HandValue.Value = 1
        tool.GripPos = Vector3.new(0.5, -0.5, -0.3)
        wait(0.01)
        tool.GripPos = Vector3.new(0.5, -1, 0)
        wait(0.01)
        tool.GripPos = Vector3.new(0.5, -1.5, 0.5)
        wait(0.01)
        tool.GripPos = Vector3.new(0.5, -1.5, 1)
        wait(0.01)
        tool.GripPos = Vector3.new(0.5, -1.5, 1.5)
        wait(0.01)
        tool.GripPos = Vector3.new(0.5, -1, 2)
        wait(0.01)
        tool.GripPos = Vector3.new(1, -0.5, 2.5)
        wait(0.01)
        tool.GripPos = Vector3.new(1.5, 0, 3)
        wait(0.01)
        tool.GripPos = Vector3.new(2, 0.5, 3)
        wait(0.01)
        tool.GripPos = Vector3.new(2.5, 1, 3)
        wait(0.01)
        tool.GripPos = Vector3.new(3, 1.5, 3)
        wait(0.01)
        tool.GripPos = Vector3.new(2.5, 2, 2.5)
        wait(0.01)
        tool.GripPos = Vector3.new(2, 2.5, 2)
        wait(0.01)
        tool.GripPos = Vector3.new(1.5, 3, 1.5)
        wait(0.01)
        tool.GripPos = Vector3.new(1, 3.5, 1)
        wait(0.01)
        tool.GripPos = Vector3.new(0.5, 3, 0.5)
        wait(0.01)
        tool.GripPos = Vector3.new(0.5, 2.5, 0)
        wait()
    tool.lMovement.Disabled=false
end


tool.Equipped:connect(function() 
    Active = true
  gui.Visible = false
end)

tool.Unequipped:connect(function() 
    Active = false
    gui.Visible = false 
end)

script.Parent.MouseButton1Down:connect(function()
    if Debounce then 
    Debounce = false
        Start()
    wait(CoolDown)
    Debounce = true
  end
end)


function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        if Active and Debounce then
        Debounce = false
            Start()
        wait(CoolDown)
        Debounce = true
    end
    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.G)

Thanks, LukeGabrieI aka EnergyBrickz

1
If gui is a ScreenGui or SurfaceGui, it won't work because it needs to be a gui component MrLonely1221 701 — 7y

Answer this question