This is probably one of the most hardest scripts I've ever tried to dealt with, and it seems that this button still won't work. I've got the GUI to pop up, but whenever I click the button, the function won't work.
Function:
local tool = script.Parent local button = script.Parent.ControlsGui.TextButton local Debounce = true local Active = false local CoolDown = 0.01 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 button.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)
I have no errors, but I don't know why it won't fire, or work.
local tool=script.Parent local gui=tool.ControlsGui tool.Equipped:connect(function() tool.rMovement.Disabled=true tool.lMovement.Disabled=true local Player=game.Players:findFirstChild(tool.Parent.Name) if Player and tool.Parent:findFirstChild("Humanoid") then local c=gui:Clone() c.Parent=Player.PlayerGui end if tool.HandValue.Value==1 then tool.lMovement.Disabled=false else tool.rMovement.Disabled=false end end) tool.Unequipped:connect(function() gui:Destroy() -- this actually removes the GUI from the tool, so idk any alternative method. end)
-The thing is whenever I try to use WaitForChild, in the Output, it always gives me Infinite Yield Possible. -Also I have another GUI that's inside the Tool, but that has no errors. It works totally fine.
If you could help, that would be great.
Thanks, LukeGabrieI aka EnergyBrickz
Well first your cloning the GUI so then the new GUI would be in the PlayerGui. But If you add the line Gui:Destroy()
then your destroying/removing the GUI from the tool instead of the PlayerGui if your trying to remove it from screen. So instead of Gui:Destroy()
you should do c:Destroy()
because your suppose to destroy the cloned Gui otherwise your removing the place where it's cloning from.
I'm not sure if this is what your trying to do but if it is and helped then please accept answer