Simple and easy, but I would like a good thorough way of converting this script into UserInputService. I gave an attempt, but I don't think it worked at all, lol.
Original Script:
local Tool=script.Parent local V=script.Parent.HandValue.Value local keys={false,false} local debris = game:service("Debris") --[[ (- Example -) function Key(key) if (key=="o") then Tool.Movement.Disabled = true Tool.GripPos = Vector3.new(0, 0, 0) wait(0.05) Tool.Movement.Disabled = false end end ]] function Key1(key) if key then key = string.lower(key) if (key=="e") then keys[1]=true repeat if script.Parent.PowerValue.Value <= 90 then script.Parent.PowerValue.Value=script.Parent.PowerValue.Value+5 else script.Parent.PowerValue.Value=script.Parent.MaxValue.Value end wait(0.1) until keys[1]==false end if (key=="q") then keys[2]=true repeat if script.Parent.PowerValue.Value >= 10 then script.Parent.PowerValue.Value=script.Parent.PowerValue.Value-5 else script.Parent.PowerValue.Value=script.Parent.MinValue.Value end wait(0.1) until keys[2]==false end end end function Key2(key) if key then key = string.lower(key) if (key=="e") then keys[1]=false end if (key=="q") then keys[2]=false end end end function selected(mouse) mouse.KeyDown:connect(Key1) mouse.KeyUp:connect(Key2) end script.Parent.Equipped:connect(selected)
Attempted Converted Script:
local function onInputBegan(input,gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.E then if script.Parent.PowerValue.Value <= 90 then script.Parent.PowerValue.Value=script.Parent.PowerValue.Value+5 else script.Parent.PowerValue.Value=script.Parent.MaxValue.Value end wait(0.1) elseif input.KeyCode == Enum.KeyCode.Q then repeat if script.Parent.PowerValue.Value >= 10 then script.Parent.PowerValue.Value=script.Parent.PowerValue.Value-5 else script.Parent.PowerValue.Value=script.Parent.MinValue.Value end wait(0.1) end end end end
Thanks,
LukeGabrieI aka EnergyBrickz