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

Can someone tell me what wrong with this light keybind localscript?

Asked by 6 years ago
local light = script.Parent.Parent.Parent.Body.Li
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
    if key == "z" then
        light.Lamp.Lighto.Light.Visible = true
    else
        light.Lamp.Lighto.Light.Visible = false
    end
end)
game.Players.LocalPlayer:GetMouse().KeyUp:connect(function(key)
    if key == "z" then
        light.Lamp.Lighto.Light.Visible = true
    else
        light.Lamp.Lighto.Light.Visible = false
    end
end)

i have a picture to https://gyazo.com/3e6a07a3f427c5ab97c84b1848cbcd94 and https://gyazo.com/637b682a109629f07e12158c6786a5ea

0
Mouse.KeyDown is deprecated, use UserInputServer.InputBegan instead theking48989987 2147 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Mouse.KeyDown is deprecated, use UserInputService. It is much better it can be found on the wiki.

0
like this? V Thomasdj01 -22 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

like this?

local light = script.Parent.Parent.Parent.Body.Li
game.Players.LocalPayer:UserInputServer().InputBegan:connect(function(key)
    if key == "z" then
        light.Lamp.Lighto.Light.Visible = true
    else
        light.Lamp.Lighto.Light.Visible = false
    end
end)
game.Players.LocalPlayer:UserInputServer().InputBegan:connect(function(key)
    if key == "z" then
        light.Lamp.Lighto.Light.Visible = true
    else
        light.Lamp.Lighto.Light.Visible = false
    end
end)

Answer this question