Hello all, recently I developed a script that when a players mouse goes over a NPC a gui appears using tweening ect. The gui then displays "Press F to open the store". This has all been scripted so when the "f" key is pressed the visibility of the store gui is set to true. And goes as following . However upon pressing the F key nothing happens, could I please have some help?
local uis = game:GetService("UserInputService") local raus,vaus local StoreGui = game.StarterGui.Store.StoreGui local settings = { key = "e" } local player = game.Players.LocalPlayer local mouse = player:GetMouse() while true do if mouse.Target ~= nil and mouse.Target.Parent:FindFirstChild("HumanoidRootPart") and not game.Players:FindFirstChild(mouse.Target.Parent.Name) then print("Works") if mouse.Target.Position.X - player.Character.HumanoidRootPart.Position.X < 10 and mouse.Target.Position.Z - player.Character.HumanoidRootPart.Position.Z < 10 then print("works2") script.Parent.Frame:TweenPosition(UDim2.new(0.12 , 0 ,0.1 , 0) , "Out" , "Linear" , 0.5) else script.Parent.Frame:TweenPosition(UDim2.new(0.12 , 0 ,1 , 0) , "In" , "Linear" , 0.5) end else script.Parent.Frame:TweenPosition(UDim2.new(0.12 , 0 ,1 , 0) , "In" , "Linear" , 0.5) end wait() end local input = uis.InputBegan.connect(function(key,gpe) if key.KeyCode == Enum.KeyCode[string.upper(settings.key)] and vaus ~= true then StoreGui.visible = true end end)
local uis = game:GetService("UserInputService") local raus,vaus local StoreGui = game.StarterGui.Store.StoreGui local settings = { key = "F" } local player = game.Players.LocalPlayer local mouse = player:GetMouse() while true do if mouse.Target ~= nil and mouse.Target.Parent:FindFirstChild("HumanoidRootPart") and not game.Players:FindFirstChild(mouse.Target.Parent.Name) then print("Works") if mouse.Target.Position.X - player.Character.HumanoidRootPart.Position.X < 10 and mouse.Target.Position.Z - player.Character.HumanoidRootPart.Position.Z < 10 then print("works2") script.Parent.Frame:TweenPosition(UDim2.new(0.12 , 0 ,0.1 , 0) , "Out" , "Linear" , 0.5) else script.Parent.Frame:TweenPosition(UDim2.new(0.12 , 0 ,1 , 0) , "In" , "Linear" , 0.5) end else script.Parent.Frame:TweenPosition(UDim2.new(0.12 , 0 ,1 , 0) , "In" , "Linear" , 0.5) end wait() end local input = uis.InputBegan.connect(function(key,gpe) if key.KeyCode == Enum.KeyCode[string.upper(settings.key)] and vaus ~= true then StoreGui.Visible = true end end)
You set it to the wrong key. The key that is pressed must always be a capital letter (if the key is a letter).
Also, the visible property is deprecated. Use its capitalized counterpart, Visible.