Howdy
I’ve created a script that changes the UI when a player presses a button (up and down). This works perfectly fine and this is how I want it. But, I have a problem with this. The player can also move with the arrow up and down keys and what I am trying to achieve is when the UI is open, and when the player presses the arrow up or down key that they don’t move but just stay in their position.
I’ve already tried to freeze the player but with no success, the player can still move. See my code here.
LocalScript
-- // SERVICES \\ --
local UserInputService = game:GetService("UserInputService")
local playerService = game:GetService("Players")
-- // VARIABLES \\ --
local localPlayer = playerService.LocalPlayer
local directionEvent = script.Parent.evs.direction
-- // MAIN SCRIPT \\ --
UserInputService.InputBegan:Connect(function(key, gpe)
if gpe then return end
if key.KeyCode == Enum.KeyCode.Up or key.KeyCode == Enum.KeyCode.Down then
directionEvent:FireServer(key.KeyCode)
end
end)
Script
local function moveButton(localPlayer, button)
if player ~= localPlayer then player:Kick("You are firing events for other players!") return end
-- This is where I tried to freeze the player, but with no success
end
-- // EVENTS \\ --
directionEvent.OnServerEvent:Connect(moveButton)
Sincerly, ConstructedDamage