I don’t think that’s the case. Function run on the same thread as the main script.
Take a case like this
function waitTenSec()
wait(10)
end
local start = tick()
waitTenSec()
waitTenSec()
print(tick()-start)
This will print out 20
I don’t think that’s the case. Function run on the same thread as the main script.
Take a case like this
function waitTenSec()
wait(10)
end
local start = tick()
waitTenSec()
waitTenSec()
print(tick()-start)
This will print out 20
yes, i am using your code
local Players = game:GetService("Players")
local visited = {}
local function OnCharacterAdded(char)
while char.Humanoid.Health > 0 do
wait(0.1)
for i = -25,1 do
local zPos = math.floor((char.HumanoidRootPart.Position.Z + i * 100) / 100 + 0.5) * 20
if visited[zPos] == nil then
visited[zPos] = script.Room:Clone()
local p = visited[zPos]
p:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,1.5,zPos)))
p.Parent = workspace.Room
end
end
end
end
local function OnPlayerAdded(plr)
if plr.Character then
OnCharacterAdded(plr.Character)
end
plr.CharacterAdded:Connect(OnCharacterAdded)
end
for _, Player in ipairs(Players:GetPlayers()) do
OnPlayerAdded(Player)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
try changing
local function OnCharacterAdded(char)
//your code
end
To
local OnCharacterAdded = coroutine.wrap(function (char)
//your code
end)
make sure to change//your code with what you have right now
great now it doesn’t work in studio either
I responded to your other topic.
Response: