This sounds really complicated, but basically, I'm creating a GUI inside a Tool that is basically cloned whenever the Tool is equipped, and inside this GUI I have a button, and what this button does is that whenever it is clicked on, a specific key on the keyboard is pressed. I am a really beginning scripter, and if you guys could fix my script up, it would be awesome!
local Player = script.Parent.Parent.Parent.Parent local ScreenGui = script.Parent.Parent local Tool=script.Parent.Parent.Parent local keys={false,false} local debris = game:service("Debris") ------------------------------------------------ local aroundRight="g" -- the key pressed ------------------------------------------------- while true do wait() if Player:IsA("Player") then function AroundRight(key) --this is what happens to the tool (basically a basketball) if (key==aroundRight) then 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 -- basically I have it where I can use the basketball on both my left hand and right hand. end else break end else break end end ScreenGui:Destroy() --i want it so that whenever the Tool is unequipped, it would remove the GUI Tool.Equipped:connect(function() script.Parent.MouseButton1Click:connect(AroundRight) -- basically the function where when it clicks it connects the upper script. end)
I don't know if I'm suppose to use UserInputService with it or not, or if there's an even simpler method like ContextActionService, but I don't know how to develop the script if I ever tried using those services, lol. (Yet alone even know how to create one.)
All in all, a button that whenever it is clicked on, a key on the keyboard will be equivalent to it, and once the ball is unequipped, the button will disappear. Also, if you could implement a debounce whenever the button is clicked on that would be wonderful! :)
Thanks, LukeGabriel aka EnergyBrickz
I think i got it. The problem that i see was in the while
loop. The code below while
will be executed when its condiction is false. As your loop's condiction is directally set to true
, the code will not be executed anyhow...