Just a tiny bug

The text label should be displaying “Arena” + a number but its just displaying “Arena”

local number = 1

prompt.Triggered:Connect(function()

	script.Parent.Enabled = true
	script.Parent.Parent.InvAndHotbar.Enabled = false
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.CamPositions["1"].CFrame
	arena.Text = "Arena "..number

	local rightArrowConn = rightArrow.MouseButton1Click:Connect(function()
		if number == 8 then
			cam.CFrame = camFolder["1"].CFrame
			number = 1
			arena.Text = "Arena "..number
		else
			cam.CFrame = camFolder[number +1].CFrame
			number = number +1
			arena.Text = "Arena "..number
		end
		wait(.1)
	end)
7 Likes

Try using tostring()

local number = 1
local numberToText = tostring(number)

arena.Text = "" --this is optional

prompt.Triggered:Connect(function()

	script.Parent.Enabled = true
	script.Parent.Parent.InvAndHotbar.Enabled = false
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.CamPositions["1"].CFrame
	arena.Text = "Arena "..numberToText
6 Likes

you need to use tostring() i think and note instead of putting number = number + 1 you can just do number += 1

1 Like

Still not working, any idea why?

local number = 1
local numberToText = tostring(number)

prompt.Triggered:Connect(function()

	script.Parent.Enabled = true
	script.Parent.Parent.InvAndHotbar.Enabled = false
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.CamPositions["1"].CFrame
	arena.Text = "Arena " .. numberToText

	local rightArrowConn = rightArrow.MouseButton1Click:Connect(function()
		if number == 8 then
			cam.CFrame = camFolder["1"].CFrame
			number = 1
			numberToText = tostring(number)
			arena.Text = "Arena " .. numberToText
		else
			cam.CFrame = camFolder[number +1].CFrame
			number = number +1
			numberToText = tostring(number)
			arena.Text = "Arena " .. numberToText
		end
		wait(.1)
	end)
1 Like
  1. You may use task.wait instead of wait, wait is an older version of task.wait that may be deprecated eventually.
  2. You may also use number+=1 instead of number=number+1.
  3. You may do cam.CFrame=camFolder[tostring(number)] after setting the number, Note "1" may be faster than using tostring (But, I haven’t benchmarked to prove this.)
  4. Check the Output for errors, if there’s one on cam.CFrame=camFolder[number+1].CFrame then consider using tostring
  5. Are you setting arena to the TextLabel?
    (This is probably true, you may be showing only a part of your code.)

If there’s no error related to above, it may be another reason for the error.

2 Likes
local plr = game.Players.LocalPlayer
local char = plr.Character or plr:WaitForChild("Character")

local prompt = workspace:FindFirstChild("The Goblet of Fire").Model.Model.Handle.ProximityPrompt
local camFolder = workspace.CamPositions
local cam = workspace.CurrentCamera
local rightArrow = script.Parent.Frame.RightArrow
local exitButton = script.Parent.Frame.Exit

local number = 1
local numberToText = tostring(number)

prompt.Triggered:Connect(function()

	plr.PlayerGui.Security.Enabled = true
	plr.PlayerGui.InvAndHotbar.Enabled = false
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.CamPositions["1"].CFrame
	plr.PlayerGui.Security.Arena.Text = "Arena " .. numberToText

	local rightArrowConn = rightArrow.MouseButton1Click:Connect(function()
		if number == 8 then
			cam.CFrame = camFolder["1"].CFrame
			number = 1
			numberToText = tostring(number)
			plr.PlayerGui.Security.Arena.Text = "Arena " .. numberToText
		else
			number += 1
			numberToText = tostring(number)
			cam.CFrame = camFolder[numberToText].CFrame
			plr.PlayerGui.Security.Arena.Text = "Arena " .. numberToText
		end
		task.wait(.1)
	end)

	exitButton.MouseButton1Click:Once(function() -- only listens once
		rightArrowConn:Disconnect() -- disconnects the function
		plr.PlayerGui.Security.Enabled = false
		plr.PlayerGui.InvAndHotbar.Enabled = true
		cam.CameraType = Enum.CameraType.Custom
		cam.CFrame = workspace.CamPositions["1"].CFrame
		number = 1
	end)
end)

image
Thats the whole lot of it (its still not working)

Weird.

  1. I didn’t think tostring did anything, since Roblox’s LUAU ‘changes’ value type if possible.
    That’s why,if you skip tostring it shouldn’t be a problem. But, keep it and then try changing it if it improves performance. Source.
  2. You may create a varialbe instead of plr.PlayerGui.Security.Arena
  3. tostring shouldn’t give an empty string, unless very specific things happen, Did you set the text to ‘Arena’ on start?

I honestly don’t know what might be the issue, you set up everything correctly (I think.).
Did you check the Output?

1 Like

The fault resides in your code. I don’t really understand why you would connect a function to a player’s mouse button input in an already connected function. Pretty sure it will never execute. You have to separate the promt.Triggered and rightArrow.MouseButton1Click into two separate functions.

Also, using tostring() is completely unnecessary. LuaU will convert all value data types into strings when the .. operator is used.

For example, this script works:

local screenGui = script.Parent
local textLabel = screenGui:WaitForChild("TextLabel")

local number = 1

while task.wait(1) do
	textLabel.Text = "Amount of seconds wasted: " .. number
	number+= 1
end
1 Like

Are you sure that the text you wanna change is arena? I am seeing no errors in the code.

Is there maybe another script interfering the text?

1 Like

Theres no error messages, and the text label has “Arena” in it by default.

Like this? Still not working for some reason.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr:WaitForChild("Character")

local prompt = workspace:FindFirstChild("The Goblet of Fire").Model.Model.Handle.ProximityPrompt
local camFolder = workspace.CamPositions
local cam = workspace.CurrentCamera
local rightArrow = script.Parent.Frame.RightArrow
local exitButton = script.Parent.Frame.Exit

local number = 1

local rightArrowConn = rightArrow.MouseButton1Click:Connect(function()
	if number == 8 then
		cam.CFrame = camFolder["1"].CFrame
		number = 1
		plr.PlayerGui.Security.Arena.Text = "Arena " .. number
	else
		number += 1
		cam.CFrame = camFolder[number].CFrame
		plr.PlayerGui.Security.Arena.Text = "Arena " .. number
	end
	task.wait(.1)
end)

exitButton.MouseButton1Click:Once(function() -- only listens once
	rightArrowConn:Disconnect() -- disconnects the function
	plr.PlayerGui.Security.Enabled = false
	plr.PlayerGui.InvAndHotbar.Enabled = true
	cam.CameraType = Enum.CameraType.Custom
	cam.CFrame = workspace.CamPositions["1"].CFrame
	number = 1
end)

prompt.Triggered:Connect(function()
	plr.PlayerGui.Security.Enabled = true
	plr.PlayerGui.InvAndHotbar.Enabled = false
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.CamPositions["1"].CFrame
	plr.PlayerGui.Security.Arena.Text = "Arena " .. number
end)
	

Edit: I changed the base value to “Arena 1” but as soon as I join the game it just turns to “Arena” so its like its being changed somehow.

I believe it was the improper use of tostring()

plr.PlayerGui.Security.Arena.Text = tostring("Arena " .. number)

I made a quick script and this does exactly what you asked

my very small script:

local tool = script.Parent
local number = 1

tool.Activated:Connect(function()
	if number == 8 then
		tool.Name = tostring("Arena "..number)
		number = 1
	else
		tool.Name = tostring("Arena "..number)
		number += 1
	end
end)
1 Like

Like this? Still no luck unfortunatly.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr:WaitForChild("Character")

local prompt = workspace:FindFirstChild("The Goblet of Fire").Model.Model.Handle.ProximityPrompt
local camFolder = workspace.CamPositions
local cam = workspace.CurrentCamera
local rightArrow = script.Parent.Frame.RightArrow
local exitButton = script.Parent.Frame.Exit

local screenGui = script.Parent
local textLabel = screenGui.Arena

local number = 1

textLabel.Text = tostring("Arena " .. number)

local rightArrowConn = rightArrow.MouseButton1Click:Connect(function()
	if number == 8 then
		cam.CFrame = camFolder["1"].CFrame
		number = 1
		textLabel.Text = tostring("Arena " .. number)
	else
		number += 1
		cam.CFrame = camFolder[tostring(number + 1)].CFrame
		textLabel.Text = tostring("Arena " .. number)
	end
	task.wait(.1)
end)

exitButton.MouseButton1Click:Once(function() -- only listens once
	rightArrowConn:Disconnect() -- disconnects the function
	plr.PlayerGui.Security.Enabled = false
	plr.PlayerGui.InvAndHotbar.Enabled = true
	cam.CameraType = Enum.CameraType.Custom
	cam.CFrame = workspace.CamPositions["1"].CFrame
	number = 1
end)

prompt.Triggered:Connect(function()
	plr.PlayerGui.Security.Enabled = true
	plr.PlayerGui.InvAndHotbar.Enabled = false
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.CamPositions["1"].CFrame
	textLabel.Text = tostring("Arena " .. number)
end)

I put some prints in, see where it goes wrong
the P in the prints stands for Print

local plr = game.Players.LocalPlayer
local char = plr.Character or plr:WaitForChild("Character")

local prompt = workspace:FindFirstChild("The Goblet of Fire").Model.Model.Handle.ProximityPrompt
local camFolder = workspace.CamPositions
local cam = workspace.CurrentCamera
local rightArrow = script.Parent.Frame.RightArrow
local exitButton = script.Parent.Frame.Exit

local screenGui = script.Parent
local textLabel = screenGui.Arena

local number = 1

textLabel.Text = tostring("Arena " .. number)
print(tostring("P1 Arena "..number))

local rightArrowConn = rightArrow.MouseButton1Click:Connect(function()
	if number == 8 then
		cam.CFrame = camFolder["1"].CFrame
		number = 1
		textLabel.Text = tostring("Arena " .. number)
print(tostring("P2 Arena "..number))
	else
		number += 1
		cam.CFrame = camFolder[tostring(number + 1)].CFrame
		textLabel.Text = tostring("Arena " .. number)
print(tostring("P3 Arena "..number))
	end
	task.wait(.1)
end)

exitButton.MouseButton1Click:Once(function() -- only listens once
	rightArrowConn:Disconnect() -- disconnects the function
	plr.PlayerGui.Security.Enabled = false
	plr.PlayerGui.InvAndHotbar.Enabled = true
	cam.CameraType = Enum.CameraType.Custom
	cam.CFrame = workspace.CamPositions["1"].CFrame
	number = 1
end)

prompt.Triggered:Connect(function()
	plr.PlayerGui.Security.Enabled = true
	plr.PlayerGui.InvAndHotbar.Enabled = false
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.CamPositions["1"].CFrame
	textLabel.Text = tostring("Arena " .. number)
print(tostring("P4 Arena "..number))
end)
1 Like

Tell me if you could, what is under the “Arena” textlabel?

1 Like

ui ratio and ui text size constraint

gfdgdfgfdgd

Ok so firstly it prints(“P1 Arena 1”) when i first join the game.

image

Then it prints P4 arena 1 when i interact with proximity
then the rest are when i click next a few times.

(The text label doesn’t change the whole time)


I switched mine from a tool to a textbutton and it still works,
Can you check if your TextLabel’s text changes?
image
If it doesn’t change then I think you have the wrong textlabel hooked up in textLabel.Text
It should be changing though as its printing correctly

You did say something else was changing it to just “Arena” so maybe theres also another script controlling it?

2 Likes

Yeah theres defiantly something funny going on because no matter what i change the text to it gets changed back to arena, but i don’t think i have any other scripts on it, i’ll have another look, thanks.

Thank you very much for your help, after all that I think it was something to do with the ui constraints. I deleted the label and added it in again and all worked perfectly, thank you very much for your help

3 Likes