Hi, basically, in my game, there’s a main server script that handles the game, and it will clone the number of maps needed from ServerStorage ( 2 clones for 2 players ), the problem is since the script are all the same, they will both listen to events and in the case of the map, will use the first string of numbers that a player has typed in, and mess up everything.
I’d like to know if there’s a way to avoid that without generating a RemoteEvent for each map
script :
local remote = game.ReplicatedStorage.RemoteEvents.EnableKeycode
local TweenService = game:GetService("TweenService")
local door = script.Parent.Parent
local doorCharniere = door.PrimaryPart
local doorTweenInfo = TweenInfo.new()
remote.OnServerEvent:Connect(function(player,text)
local CodeValue = door.Parent.Parent.PC.Screen.Code
local GUI = player.PlayerGui.KeycodeGUI
local fix = GUI.Frame.Frame.CodeSee
local doorCharTween = TweenService:Create(doorCharniere, doorTweenInfo, {CFrame = doorCharniere.CFrame * CFrame.Angles(0, math.rad(120), 0)})
if tonumber(text) == CodeValue.Value then
script.Parent.Correct:Play()
fix.Text = "Correct code"
fix.TextColor3 = Color3.fromRGB(0, 200, 0)
wait(1)
fix.Text = ""
fix.TextColor3 = Color3.fromRGB(255, 255, 255)
script.Parent.DoorOpen:Play()
doorCharTween:Play()
script.Parent.Prompt.Enabled = false
else
script.Parent.Incorrect:Play()
fix.Text = "Incorrect Code"
fix.TextColor3 = Color3.fromRGB(200, 0, 0)
wait(1)
fix.Text = ""
fix.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end)
script.Parent.Prompt.Triggered:Connect(function(player)
remote:FireClient(player)
end)
The script works fine when only 1 map is present
If this is not clear please tell me i’ll re-explain