Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

2 scripts are almost the same thing, but why doesn't the first one work?

Asked by 4 years ago

I tried to make a local script about UserInputService, my first script is:

local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
mouse = player:GetMouse()
UIS.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        print("you're pressing down a key")
    end
end)
UIS.InputEnded:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.KeyBoard  then
        print("you stopped pressing a key")
    end

end)

but when i pressed play, i got an error: Keyboard is not a valid EnumItem

after that, i made another script:


local player = game.Players.LocalPlayer local UIS = game:GetService("UserInputService") mouse = player:GetMouse() UIS.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then print("you're pressing down a key") end end) UIS.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then print("you stopped pressing a key") end end)

I changed Keyboard to MouseButton1 and it works perfectly fine What is the problem here?

0
On line 10 you spelled "Keyboard" like "KeyBoard". It should be "Keyboard". climethestair 1663 — 4y
0
ohhh ok thanks Creeperdo123 -17 — 4y

Answer this question