Map Name and creator of map display when map cutscene plays

I am trying to make a game where a random map is selected. That’s all working fine. It’s just the chosen map gui and the creator of the map gui. It shows up as intended, but then repeats itself before the cutscene ends. (status is a value)


while true do
	
	
	if status.Value == "Caves" then
		
		for i = 1,5 do
			mapname.Text = string.sub("Caves",1,i)
			task.wait(0.1)
		end
		
		for i = 1,26 do
			creators.Text = string.sub("Created by ---------------",1,i)
			task.wait(0.1)
		end
		
		wait(4)
		mapname.Text = ""
		creators.Text = ""
	
	elseif status.Value == "Harbour" then
		
		for i = 1,7 do
			mapname.Text = string.sub("Harbour",1,i)
			task.wait(0.1)
		end

		for i = 1,26 do
			creators.Text = string.sub("Created by ---------------",1,i)
			task.wait(0.1)
		end
		
		wait(4)
		mapname.Text = ""
		creators.Text = ""
	
	elseif status.Value == "Magical Forest" then
		
		for i = 1,14 do
			mapname.Text = string.sub("Magical Forest",1,i)
			task.wait(0.1)
		end

		for i = 1,26 do
			creators.Text = string.sub("Created by ---------------",1,i)
			task.wait(0.1)
		end
		
		wait(4)
		mapname.Text = ""
		creators.Text = ""

else
	mapname.Text = ""
	creators.Text = ""
	end
	
	task.wait(0.1)
end

If anyone could help make it not repeat itself, please let me know!

First of all, is this inside your gui’s local script or inside the server manager? Second, you could just use Value.Changed instead of updating constantly. I would also recommend using a value/table for each map so that you don’t have to use an If statement every time you want to add a new map.

You could try getting the property changed signal

status:GetPropertyChangedSignal("Value"):Connect(function()
	if status.Value == "Caves" then
		--continue writing code
	end
end)

Edit: @snowingwings220’s solution also works

I just updated the script to utilise :GetPropertyChangedSignal but now it’s not playing at all-

@snowingwings220 this is a local script but there is also a serverscript changing the value of status.

status:GetPropertyChangedSignal("Value"):Connect(function()
	if status.Value == "Caves" then
		if status.Value == "Caves" then

			for i = 1,5 do
				mapname.Text = string.sub("Caves",1,i)
				task.wait(0.1)
			end

			for i = 1,26 do
				creators.Text = string.sub("Created by DevInfinityPlus",1,i)
				task.wait(0.1)
			end
			
			creators.Text = ""
			mapname.Text = ""

		elseif status.Value == "Harbour" then

			for i = 1,7 do
				mapname.Text = string.sub("Harbour",1,i)
				task.wait(0.1)
			end

			for i = 1,26 do
				creators.Text = string.sub("Created by DevInfinityPlus",1,i)
				task.wait(0.1)
			end
			
			creators.Text = ""
			mapname.Text = ""

		elseif status.Value == "Magical Forest" then

			for i = 1,14 do
				mapname.Text = string.sub("Magical Forest",1,i)
				task.wait(0.1)
			end

			for i = 1,26 do
				creators.Text = string.sub("Created by DevInfinityPlus",1,i)
				task.wait(0.1)
			end
			
			creators.Text = ""
			mapname.Text = ""
			
		end
	end
end)

It just literally doesn’t say the map at all.

ServerScript if needed
local lobby = game.Workspace.Lobby
local maps = game.ReplicatedStorage.Maps:GetChildren()
local status = game.ReplicatedStorage.Status
local maptextbool = game.ReplicatedStorage.MapTextDispayBool
local runService = game:GetService("RunService")
maptextbool = false

function StartCutscene(map)
	-- Trigger cutscene on the clients
	game.ReplicatedStorage.StartCutscene:FireAllClients(map)

	-- Wait for the cutscene to finish
	local cutsceneDuration = 10
	wait(cutsceneDuration)

	-- Teleport players
	for _, player in ipairs(game.Players:GetPlayers()) do
		local character = player.Character
		if character then
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart then
				if map.Name == "Caves" then
					humanoidRootPart.CFrame = game.Workspace.CaveSLs:getChildren()[math.random(1,#game.Workspace.CaveSLs:GetChildren())].CFrame
				end
				
				if map.Name == "Harbour" then
					humanoidRootPart.CFrame = game.Workspace.HarbourSLs:getChildren()[math.random(1,#game.Workspace.HarbourSLs:GetChildren())].CFrame
				end
				
				if map.Name == "Magical Forest" then
					humanoidRootPart.CFrame = game.Workspace.ForestSLs:getChildren()[math.random(1,#game.Workspace.ForestSLs:GetChildren())].CFrame
				end
			end
		end
	end

	-- Gameplay countdown
	for i = 30, 0, -1 do
		status.Value = i
		wait(1)
	end

	-- Return to lobby
	for _, player in ipairs(game.Players:GetPlayers()) do
		local character = player.Character
		if character then
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart then
				humanoidRootPart.CFrame = lobby.TeleportPoint.CFrame
			end
		end
	end

	-- Cleanup
	map:Destroy()
	
	game.Workspace.SpawnLocationLobby.Enabled = true
	
	for i,v in pairs(game.Workspace.CaveSLs:GetChildren()) do 
		if v:IsA("SpawnLocation") then
			v.Enabled = false 
		end 
	end
	
	for i,v in pairs(game.Workspace.ForestSLs:GetChildren()) do 
		if v:IsA("SpawnLocation") then
			v.Enabled = false 
		end 
	end
	
	for i,v in pairs(game.Workspace.HarbourSLs:GetChildren()) do 
		if v:IsA("SpawnLocation") then
			v.Enabled = false 
		end 
	end
	
end

while true do
	-- Intermission countdown
	for i = 20, 0, -1 do
		status.Value = i .. " seconds of intermission..."
		wait(1)
		if i == 0 then
			game.Workspace.SpawnLocationLobby.Enabled = false
		end
	end

	-- Map selection
	local chosenMap = maps[math.random(1, #maps)]
	local clonedMap = chosenMap:Clone()
	clonedMap.Parent = game.Workspace
	status.Value = chosenMap.Name
	maptextbool = true
	print(status.Value)
	
	if clonedMap.Name == "Caves" then
		for i,v in pairs(game.Workspace.CaveSLs:GetChildren()) do 
			if v:IsA("SpawnLocation") then
				v.Enabled = true
			end 
		end
		
	elseif clonedMap.Name == "Harbour" then
		for i,v in pairs(game.Workspace.HarbourSLs:GetChildren()) do 
			if v:IsA("SpawnLocation") then
				v.Enabled = true
			end 
		end
		
	elseif clonedMap.Name == "Magical Forest" then
		for i,v in pairs(game.Workspace.ForestSLs:GetChildren()) do 
			if v:IsA("SpawnLocation") then
				v.Enabled = true
			end 
		end
	end

	-- Start the cutscene on the server
	StartCutscene(clonedMap)
end

Are you sure it’s not firing at all? that code (if the “status” variable is a value) should fire every time the value changes. Make sure the “status” variable is actually the value for which map is currently ingame.

You checked if the value of status was "Caves" twice

status:GetPropertyChangedSignal("Value"):Connect(function()
	if status.Value == "Caves" then

		for i = 1,5 do
			mapname.Text = string.sub("Caves",1,i)
			task.wait(0.1)
		end

		for i = 1,26 do
			creators.Text = string.sub("Created by DevInfinityPlus",1,i)
			task.wait(0.1)
		end

		creators.Text = ""
		mapname.Text = ""

	elseif status.Value == "Harbour" then

		for i = 1,7 do
			mapname.Text = string.sub("Harbour",1,i)
			task.wait(0.1)
		end

		for i = 1,26 do
			creators.Text = string.sub("Created by DevInfinityPlus",1,i)
			task.wait(0.1)
		end

		creators.Text = ""
		mapname.Text = ""

	elseif status.Value == "Magical Forest" then

		for i = 1,14 do
			mapname.Text = string.sub("Magical Forest",1,i)
			task.wait(0.1)
		end

		for i = 1,26 do
			creators.Text = string.sub("Created by DevInfinityPlus",1,i)
			task.wait(0.1)
		end

		creators.Text = ""
		mapname.Text = ""

	end
end)

Here’s the correct script

1 Like

It doesn’t bug like before anymore, but as soon as it finishes typing, it just disappears. Is there any way to prevent this?

Set the string to the finished string after its done.

You can also just remove this part from each if statement

creators.Text = ""
mapname.Text = ""

it’d save you some lines i guess