Hello. I’m currently making a queue system for teleporting to a specific place in which the player that touches the part will be forced to move to a teleport part behind a closed door. The closed door opens upon meeting the requirements for entry. For emersion purposes, I want to disable the player controls temporarily as the player’s character walks to the desired location. Wondering if this is possible to do from a script within the part that checks the player’s credentials, or if this is only possible from a LocalScript
. Everything else works as expected except the disabling of the player’s controls. Here is the code I have currently:
-- Get instances
local hitbox = script.Parent
local teleport = hitbox.Parent.Teleport
-- Function that opens the door upon verifying the player and the level selection value
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
-- Get the player object and player level selection value
local character = hit.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(character)
local selection = player:FindFirstChild("Selection")
if player and selection.Value == 1 then
local playerControls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
playerControls:Disable()
hit.Parent.Humanoid:MoveTo(teleport.Position)
task.wait(3)
playerControls:Enable()
end
end
end)