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

Why do I get errors on my KeyDown Script?

Asked by 9 years ago
bin = script.Parent
player = script.Parent.Parent.Parent
enabled = true
function onKeyDown(key) 
key:lower() 
if key == "x" then 

if bin.Prevent.Value == 1
        then
        return end 

        bin.Prevent.Value = 1

local player = game.Players.LocalPlayer
if player == nil then return end
enabled = false
RightShoulder = player.Character.Torso["Right Shoulder"]
LeftShoulder = player.Character.Torso["Left Shoulder"]
Run = game:GetService("RunService")
for i = 1, 12 do
LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0., -0.15)
RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0., 0.15)
    Run.Stepped:wait(0.005)
            end

        for i = 1, 1 do
        x2 = Instance.new("Part")
        x2.BrickColor = BrickColor.new("Light blue")
        x2.Transparency = .3
        x2.Material = "Plastic"
        x2.Size = Vector3.new(10,1,10)
        x2.TopSurface = "Smooth"
        x2.BottomSurface = "Smooth"
        x2.Shape = "Block"
        x2.CanCollide = true
        x2.Anchored = true
        x2.Name = player.Name
        x2.CFrame = player.Character.Torso.CFrame*CFrame.new(0, 0, -5)*CFrame.fromEulerAnglesXYZ(-1.6, 0, 0)
        x2.Parent = game.Workspace
        game.Debris:AddItem(x2, 7)
        wait(0.01)
        end

        for i = 1, 12 do
            LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0., 0.15)
                RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0., -0.15)
            Run.Stepped:wait(0.01)

           end
      wait(2)
bin.Prevent.Value = 0

end


function onSelected(mouse) 
mouse.KeyDown:connect(onKeyDown) 
end 
end
script.Parent.Selected:connect(onSelected)

Some errors I get are

16:56:32.410 - Attempt to connect failed: Passed value is not a function 16:56:32.411 - Script 'Players.Player1.Backpack.Gray KeyDown!.Ice-Make: Sheild', Line 60 16:56:32.412 - Stack End I get this error when I select the hopperbin 16:56:33.879 - attempt to call a nil value 16:56:34.716 - attempt to call a nil value

1 answer

Log in to vote
0
Answered by 9 years ago

KeyDown was deprecated about a month or two ago. Please use the UseInputService.

Ad

Answer this question