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

Why will the FE script stop when I press another button?

Asked by 6 years ago

Ok so I would have 1 tool. I would put to RemoteEvent in each one. If I were too press "r" it would create a brick that is black. If i press "q" I would create a brick that is red. But for some reason when I for Ex. Press "q" before "r" the black brick would appear but the red one would never. Why? Local script

--Local script--
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
local en = true--Debounce--
Tool = script.Parent


Tool.Equipped:Connect(function()
Mouse.KeyDown:connect(function(Key)
    if Key == "e" then
        if not en then return end
        en = false
        Tool.RemoteEvent:FireServer(Key)
    end
end)
end)

Local script

--Local script--
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
local en = true--Debounce--
Tool = script.Parent

Tool.Equipped:Connect(function()
Mouse.KeyDown:connect(function(Key)
    if Key == "r" then
        if not en then return end
        en = false
        Tool.RemoteEvent:FireServer(Key)
    end
end)
end)

Server script

--Server script--
script.Parent.RemoteEvent.OnServerEvent:Connect(function(Key)
    local Part = Instance.new("Part")
    Part.Parent = game.Workspace
    Part.BrickColor = BrickColor.new("Really red")
end)

Server script

--Server script--
script.Parent.RemoteEvents.OnServerEvent:Connect(function(Key)
    local Part = Instance.new("Part")
    Part.Parent = game.Workspace
    Part.BrickColor = BrickColor.new("Really black")
end)

Thanks for helping me

1 answer

Log in to vote
0
Answered by 6 years ago

Mouse.KeyDown is deprecated and may soon not work. Use the context action service for setting keybinds, as it is more efficient and still supported compared to KeyDown:

https://wiki.roblox.com/index.php?title=API:Class/ContextActionService

Ad

Answer this question