Hello, guys! I am currently in the making of a multiplayer Mancala tabletop experience on Roblox. As of right now, I am working on the seating system, and I just want to make a chair that people can sit on to start games. I want to focus on the actual functionality of the chair, because when someone sits on a chair, they’re able to interact with a chair near them by triggering Proximity Prompts, breaking the system. That is why I want to temporarily disable all the other Proximity Prompts in game until the player exits from the seat.
Things I have tried mainly consisted of tinkering with Remote Events. My main idea to overcome this is by disabling the Prompt in the server script and enabling it again in a local script (for the player to get up from the seat), then enabling it for everyone in the server script whenever the player leaves the seat.
Server script (located inside each chair, disables sit Prompt as long as seat.Occupant = true)
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local prompt = script.Parent.rootPart.ProximityPrompt
local seat = script.Parent.chairSeat
local rootPart = script.Parent.rootPart
local inSeatEvent = ReplicatedStorage:WaitForChild("isSeatTaken")
local promptName = prompt:GetFullName()
local seatEventTwo = ReplicatedStorage:WaitForChild("seat2")
--[[ CFrame code ]]--
local function promptHandler()
return prompt
end
prompt.Triggered:Connect(function(player)
if not seat.Occupant then -- Not seated
isSeatTaken = true
prompt.Enabled = false
inSeatEvent:FireClient(player,prompt)
player.Character.Humanoid.JumpHeight = 0
seat:Sit(player.Character.Humanoid)
chairInAnim:Play()
wait(2)
prompt.ActionText = "Get up"
else -- Seated
isSeatTaken = false
prompt.Enabled = false
inSeatEvent:FireClient(player,prompt)
player.Character.Humanoid.JumpHeight = 7.2
player.Character.Humanoid.Jump = true
chairOutAnim:Play()
wait(2)
prompt.ActionText = "Sit"
end
end)
seatEventTwo.OnServerInvoke = promptHandler()
Local Script (located in StarterPlayerScripts, responsible for enabling Prompt only to local player)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("isSeatTaken")
local seatEventTwo = ReplicatedStorage:WaitForChild("seat2")
event.OnClientEvent:Connect(function(player,prompt)
seatEventTwo:InvokeServer(prompt)
for _, part in ipairs(workspace:GetDescendants()) do
if part:IsA("ProximityPrompt") then
part.Enabled = false
end
end
wait(2)
prompt.Enabled = true
end)
There is also a Remote Event (“isSeatTaken”) and Remote Function (“seat2”) in ReplicatedStorage
If anyone is able to give me some advice on how to tackle this problem, it would be appreciated! Apologies for messiness of code.