This was a continuation of my last question, but regardless, what the script is suppose to do is whenever this tool is Equipped, the GUI will be cloned, and from there, when the button is clicked, it will be equivalent to the G Key on the keyboard. Once it does that, it's suppose to do an animation. I have a link down at the end of these scripts.
I also have two other Local Scripts that are in relation to each other.
Here are the first two.
01 | local tool = script.Parent |
02 | local gui = tool.PowerGui |
04 | tool.Equipped:connect( function () |
05 | tool.rMovement.Disabled = true |
06 | tool.lMovement.Disabled = true |
07 | local Player = game.Players:findFirstChild(tool.Parent.Name) |
08 | if Player and tool.Parent:findFirstChild( "Humanoid" ) then |
10 | c.Parent = Player.PlayerGui |
11 | c.Frame.Script.Disabled = false |
13 | if tool.HandValue.Value = = 1 then |
14 | tool.lMovement.Disabled = false |
15 | else tool.rMovement.Disabled = false |
What this first script does is that it clones the first GUI, this GUI has no problems, it's working for me perfectly. (In this case it is called PowerGui)
I have a script that is powering this GUI. This is the script:
01 | local Player = script.Parent.Parent.Parent.Parent |
02 | local ScreenGui = script.Parent.Parent |
03 | local Frame = script.Parent |
07 | if Player:IsA( "Player" ) then |
08 | if Player.Character:findFirstChild( "ABL_Ball" ) then |
09 | Frame.Power.Text = Player.Character.ABL_Ball.PowerValue.Value |
10 | if Player.Character.ABL_Ball.HandValue.Value = = 0 then |
12 | else Frame.Hand.Text = "L" |
So, what this does, it's a basketball, and there is a PowerValue, and a HandValue. This ball, whenever it is released, has a certain power people can use it on. The HandValue, is whatever the basketball is being dribbled. This basically occurs whenever a key on the keyboard is pressed. In this case, H/L. As you can see, at the very end, it destroys the GUI. This happens whenever the tool is unequipped, or it is being released.
My problem here are these two scripts.
01 | local tool = script.Parent |
02 | local gui = tool.ControlsGui |
04 | tool.Equipped:connect( function () |
05 | tool.rMovement.Disabled = true |
06 | tool.lMovement.Disabled = true |
07 | local Player = game.Players:findFirstChild(tool.Parent.Name) |
08 | if Player and tool.Parent:findFirstChild( "Humanoid" ) then |
10 | c.Parent = Player.PlayerGui |
11 | c.TextButton.LocalScript.Disabled = false |
13 | if tool.HandValue.Value = = 1 then |
14 | tool.lMovement.Disabled = false |
15 | else tool.rMovement.Disabled = false |
This is equivalent to the very first one, in fact, I'm pretty sure it works, but I want it to be perfect according to this script below:
01 | local tool = script.Parent.Parent.Parent |
02 | local gui = script.Parent.Parent |
03 | local uis = game:GetService( "UserInputService" ) |
04 | local button = script.Parent |
06 | tool.Equipped:connect( function () uis.InputBegan:connect( function (input) |
08 | if input.UserInputType = = Enum.KeyCode.G then |
09 | local keyPressed = input.KeyCode |
14 | tool.Unequipped:connect( function () gui.Visible = false end ) |
16 | script.Parent.MouseButton 1 Click:connect(Click) |
I've tried and tried, I feel like I'm missing something, but I don't know what it is. This basically is inside the GUI. Whenever the tool is equipped, I am able to do a function or a certain type of code. When the button is clicked, it's equivalent to pressing the "G" key on the keyboard.
I've really tried very hard to figure out my mistakes, but there's so much I still need to learn in order to become the very best scripter I can possibly be.
Here's the Link for visual reference:
Link to Visual Reference
Thank you, if you actually read through or at least skimmed, thank you (:
If you can help I will give an upvote and will accept any answers given (just have it be thorough enough for me to understand as a beginning scripter lol)
Thanks,
LukeGabrieI aka EnergyBrickz
A script would be helpful! c:
It gave me errors like,
"Passed value is not a function" (Looked it up. it has to do with the Click Function I tried to incorporate.)