You may use task.wait instead of wait, wait is an older version of task.wait that may be deprecated eventually.
You may also use number+=1 instead of number=number+1.
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.)
Check the Output for errors, if there’s one on cam.CFrame=camFolder[number+1].CFrame then consider using tostring
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.
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.
You may create a varialbe instead of plr.PlayerGui.Security.Arena
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?
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
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 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)
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