So I made a keydown function to fire if a value is true, the value is true, but the function isn't firing when I press the hotkey. It works when the value isn't even included. Here is the script:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
 showed = false
Mouse.KeyDown:connect(function(Key)
	if ((Key:lower() == script.Parent.hotkeyvalue)) then
		print("Hotkey pushed")
		if showed == false then
			showed = true
		repeat wait(0.01)
		script.Parent.Players.Position = script.Parent.Players.Position - UDim2.new(0.01, 0, 0, 0)
		until script.Parent.Players.Position.X.Scale >= 0.4
		elseif showed == true then
		repeat wait(0.01)
			showed = false
		script.Parent.Players.Position = script.Parent.Players.Position + UDim2.new(0.01, 0, 0, 0)
		until script.Parent.Players.Position.X.Scale >= 0.8	
		end
		end
end)

1 comment

0

I recommend using the TweenPosition method.