Why is task not showing up?

Hello I am trying to teach on how to script with AlvinBlox’s Video and there was a sudden error on the task.wait(5) because for some reason it was not there and in his, it showed the task command easily. Please help me!

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local Map = game.Workspace.Map
local Doll = Map.Doll
local TimerUI = Map.Timer.UI

local ROUND_DURATION_SECONDS = 60 -- 1 Minute

local SpinTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)

local OriginalHeadCFrame = Doll.Head.CFrame

local GreenLightHead = TweenService:Create(Doll.Head, SpinTweenInfo, {
	CFrame = OriginalHeadCFrame
})

local RedLightHead = TweenService:Create(Doll.Head, SpinTweenInfo, {
		CFrame = OriginalHeadCFrame * CFrame.Angles(0,math.rad(180),0) --180 Degree Rotation
})

function DressCharacterInSuit(character)
	for _, object in pairs(character:GetChildren()) do
		if object:IsA("Shirt") or object:IsA("Pants") or object:IsA("ShirtGraphic") then
			object:Destroy()
		end
	end
	
	local Shirt = Instance.new("Shirt")
	Shirt.ShirtTemplate = "rbxassetid://7597521537"
	Shirt.Parent = character
	
	local Pants = Instance.new("Pants")
	Pants.PantsTemplate = "rbxassetid://7597288954"
	Pants.Parent = character
end

function StartGame()
	local playersInRound = Players:GetPlayers()
	local winners = {}
	local spinDelay = 5
	local lastSpin = tick()
	
	for _, player in pairs(playersInRound) do
		player:LoadCharacter()
		DressCharacterInSuit(player.Character)
	end
end

-- Main Game Loop
while true do
	task.wait(10)
	StartGame()
end

image

try using wait instead of task.wait()

Let me try the script line you showed…

Try doing

local n = 10
while task.wait(n) do
StartGame()
end

Thank you for the help I didn’t know why it didn’t work maybe stupid idk…but thx!

Could you explain what you mean by “task not showing up”? Do you mean it didn’t show up in intellisense and show you other members of the task library as you typed it out? It might just be an issue of task not being recognised at the moment but that shouldn’t deter its use.

The current marked solution (post 2) suggests the wrong thing. Wait is/will be deprecated, task.wait is the proper function to be using. Your solution shouldn’t be to go back to using an old function.

4 Likes

It is ok @instanitly found the solution for me thx tho :wink:

What is the point of them changing it? If it ain’t broke don’t fix it…

I’m saying that because the solution they proposed was to use wait over task.wait, the former of which is intended to be deprecated and is an old function. You should be using task.wait as your code originally did. What’s more confusing is what your actual problem is, because I don’t know what you mean by “task is not showing up” or that “task.wait(5) had a sudden error”.

See:

wait is a function that relies on legacy 30hz pipelines and is relatively inaccurate. For heavy games it can end up waiting more time than what you specify because it needs to yield the thread for the given time as well as find an open slot to be resumed in the task scheduler.

task.wait uses Heartbeat frequency meaning more accurate waiting and it doesn’t suffer from over-waiting. Being aware of what tasks are being executed on every frame will be important going forward especially as Roblox switches to deferred programming and immediate gets removed.

I get the saying of “if it’s not broken don’t fix it” but there there’s a time and place for that saying and this isn’t one of those times. Don’t use that saying to justify complacency and bad habits with your code.

3 Likes

YES! This is what I want though! I’m used to setting times like this, a second more or less

It was to use wait idk why studio didn’t add the task thing but it is ok now thx!

1 Like

I am new to scripting and trying to learn it rn.

If you’re typing it not by itself (in your case behind .wait(10) then it won’t show. Haha

Well I didn’t know, I only needed help.

1 Like

And anyways, it doesn’t matter if it shows in autocomplete. As long as it works