Right now, I have an elevator/teleporter system to take the player (or a group of players) from one place to another. It all works as intended until I duplicate the elevator, which has a server script inside of if that listens for remoteEvents from the client.
The issue I’m facing is that since each server script within each elevator is listening for remoteEvents from the client, so when the host changes the settings which would update the surfaceGui on the elevator, then all of the elevators change their surfaceGui.
Here is a part of my client script that fires an event for the elevator server script for reference:
lobbyGui.mapSelectionFrame.Buttons.nextButton.Activated:Connect(function()
if map ~= nil then
lobbyGuiEvent:FireServer("isReady")
lobbyGui.UIPageLayout:Next()
local difficulty = tonumber(difficultyText.Text)
optionsEvent:FireServer("updateDifficulty", difficulty)
local roomAmount = tonumber(roomAmoutText.Text)
optionsEvent:FireServer("updateRoomAmount", roomAmount)
else
lobbyGui.mapSelectionFrame.Title.TextColor = BrickColor.new("Really red")
task.wait(1)
lobbyGui.mapSelectionFrame.Title.TextColor = BrickColor.new("White")
end
end)
And here’s the part of the server script that listens for that event:
local elevator = script.Parent
local surfaceGui = elevator.Entrance.SurfaceGui
local surfaceDifficulty = surfaceGui.Difficulty
local surfaceRoomAmount = surfaceGui.RoomAmount
optionsEvent.OnServerEvent:Connect(function(player, eventtype, value)
if eventtype == "updateDifficulty" then
difficulty = value
surfaceDifficulty.Text = "Difficulty: " .. tostring(difficulty)
surfaceDifficulty.Visible = true
elseif eventtype == "updateRoomAmount" then
roomAmount = value
surfaceRoomAmount.Text = "Room Amount: " .. tostring(roomAmount)
surfaceRoomAmount.Visible = true
end
end)