I am confused right now because I’ve looked through multiple sources and cannot find a solution to my problem, I am trying to move an image upwards while my F key is held down but stops moving when a certain location is reached.
Is this even possible and if so, how would I do it?
It depends on what you mean by “until a current location is reached.” If you want it to run until that image label comes in contact with another UIObject, that code will differ from one that stops at a static position, like UDim2.new(0, 200, 0, 420) for example.
Nevertheless, magic pseudo code time:
local userInputService = game:GetService("UserInputService")
local keybind = Enum.KeyCode.F
userInputService.InputBegan:Connect(inputObject, typing)
if typing then return end
if inputObject.KeyCode == keybind then
while userInputService:IsKeyDown(keybind) do
-- update the image label's position
if imageLabel.Position == thePositionYouWant then
break
end
task.wait()
end
end
end)
uis.InputBegan:Connect(function(Key)
if dd == true then return end
if Key.KeyCode == Enum.KeyCode.F and dd == false then
dd = true-- Or whatever key or input you want
Player.PlayerGui.Shotbar.Enabled = true
shotscrolling = true
timeStarted = time()
while uis:IsKeyDown(Key) do
Player.PlayerGui.Shotbar.Scroll.Position += UDim2.new(0, 0, 1, 0)
if Player.PlayerGui.Shotbar.Scroll.Position == UDim2(0.102, 0,0.301, 0) then
break
end
task.wait()
end
end
end)
when i click run it says Unable to cast token in the output