Hello,i made this UI where when you press 'D' you first of all go from 'Equipment ' to 'Item' and then when you press D again it goes to 'Skills' (Image Linked)
and when you press A it goes from 'Skills' back to 'Item' and if you press A again to 'Equipment'
(The way it switches over is by making the Orange part which is an ImageLabel Visible and invisible (Equip, Items and skills have this ImageLabel which is called Hover))
how the UI looks: https://imgur.com/a/C3KxgxY
My problem is when i press 'D' it moves to items and then after instantly without any input it goes to skills
Im sorry if i missed anything and you are confused just comment ill reply and edit the post
The Script:
Mouse.KeyDown:connect(function(key) if key == 'd' and WSM.Value == 1 and hftweened == false then if Item_Equip_Skill == 0 then sound2:Play() wait(0.1) holdframe:TweenPosition(UDim2.new(0,0,0,0),'Out' ,'Sine', 0.5 ) wait(0.5) hftweened = true EquipHover.Visible = true ItemHover.Visible = false SkillHover.Visible = false wait(0.2) Item_Equip_Skill = 1 end if Item_Equip_Skill == 1 then EquipHover.Visible = false ItemHover.Visible = true SkillHover.Visible = false wait(0.2) Item_Equip_Skill = 2 print(Item_Equip_Skill) end if Item_Equip_Skill == 2 then EquipHover.Visible = false ItemHover.Visible = false SkillHover.Visible = true wait(0.2) Item_Equip_Skill = 3 print(Item_Equip_Skill) end end end)
You should use UserInputService as KeyDown is deprecated. Also use elseif instead of ending all those if's.
-- local script local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.D and WSM.Value == 1 and hftweened == false then if Item_Equip_Skill == 0 then sound2:Play() wait(0.1) holdframe:TweenPosition(UDim2.new(0,0,0,0),'Out' ,'Sine', 0.5 ) wait(0.5) hftweened = true EquipHover.Visible = true ItemHover.Visible = false SkillHover.Visible = false wait(0.2) Item_Equip_Skill = 1 elseif Item_Equip_Skill == 1 then EquipHover.Visible = false ItemHover.Visible = true SkillHover.Visible = false wait(0.2) Item_Equip_Skill = 2 print(Item_Equip_Skill) elseif Item_Equip_Skill == 2 then EquipHover.Visible = false ItemHover.Visible = false SkillHover.Visible = true wait(0.2) Item_Equip_Skill = 3 print(Item_Equip_Skill) end end end)
I am not quite sure will this work. But I hope it will...
I found out what i did wrong i put 'if hftweened == true' in the first if and hftweened becomes false in that script itself.
thanks for the help anyway
i made some changes and fixed it my script now looks like this if you're interested :
local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.D and WSM.Value == 1 and hftweened == false then sound2:Play() wait(0.1) holdframe:TweenPosition(UDim2.new(0,0,0,0),'Out' ,'Sine', 0.5 ) wait(0.5) hftweened = true end if input.KeyCode == Enum.KeyCode.D and WSM.Value == 1 and hftweened == true then if Item_Equip_Skill == 0 then EquipHover.Visible = true ItemHover.Visible = false SkillHover.Visible = false Item_Equip_Skill = 1 elseif Item_Equip_Skill == 1 then EquipHover.Visible = false ItemHover.Visible = true SkillHover.Visible = false Item_Equip_Skill = 2 elseif Item_Equip_Skill == 2 then EquipHover.Visible = false ItemHover.Visible = false SkillHover.Visible = true Item_Equip_Skill = 3 end end end)
-- local script local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input, gpe) if gpe then return end if input.KeyCode == Enum.KeyCode.D then if WSM.Value == 1 and hftweened == false then if Item_Equip_Skill == 0 then sound2:Play() wait(0.1) holdframe:TweenPosition( UDim2.new(0,0,0,0), Enum.EasingDirection.Out , Enum.EasingStyle.Sine, 0.5 ) wait(0.5) hftweened = true EquipHover.Visible = true ItemHover.Visible = false SkillHover.Visible = false wait(0.2) Item_Equip_Skill = 1 elseif Item_Equip_Skill == 1 then EquipHover.Visible = false ItemHover.Visible = true SkillHover.Visible = false wait(0.2) Item_Equip_Skill = 2 print(Item_Equip_Skill) elseif Item_Equip_Skill == 2 then EquipHover.Visible = false ItemHover.Visible = false SkillHover.Visible = true wait(0.2) Item_Equip_Skill = 3 print(Item_Equip_Skill) end end end end)