Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

This script won't detect what happens to players or the time. Why?

I checked the script a ton of times and i can't find the error. Also keep going down until you see a message please. Please help. Thank you. And yes I use Alvin Blox turorial.

local module = {}

local status = game.ReplicatedStorage:WaitForChild("Status")

function module.Intermission(length)
	for i = length,0,-1 do
		status.Value = "Next round starts in "..i.." seconds"
		wait(1)
	end
end

function module.SelectChapter()
	local rand = Random.new()
	local chapters = game.ReplicatedStorage.Chapters:GetChildren() -- Table of all the map models
	local chosenChapter = chapters[rand:NextInteger(1,#chapters)]
	
	return chosenChapter
end

function module.ChoosePiggy(players)
	
	local RandomObj = Random.new()
	
	local chosenPiggy = players[RandomObj:NextInteger(1,#players)]
	
	return chosenPiggy
	
end

function module.DressPiggy(piggy)
	local character = game.ServerStorage.Piggy:Clone()
	character.Name = piggy.Name
	
	piggy.Character = character
	
	character.Parent = workspace
end

function module.TeleportPiggy(player)
	if player.Character then
		
		player.Character.Humanoid.WalkSpeed = 14
		
		local bat = game.ServerStorage.Tools.PiggyBat:Clone()
		bat.Parent = player.Character
		
		if player.Character:FindFirstChild("HumanoidRootPart") then
			player.Character.HumanoidRootPart.CFrame = game.Workspace.WaitingRoom.PiggyWaitingSpawn.CFrame + Vector3.new(0,5,0)
		end
		
	end
end

function module.TeleportPlayers(players, mapSpawns)
	
	
	
	for i, player in pairs(players) do
		if player.Character then
			local character = player.Character
			
			if character:FindFirstChild("HumanoidRootPart") then
				
				player.Character.Humanoid.WalkSpeed = 16
				
				local rand = Random.new()
				player.Character.HumanoidRootPart.CFrame = mapSpawns[rand:NextInteger(1, #mapSpawns)].CFrame + Vector3.new(0,10,0)
				
			end
		end
	end
	
end

function module.InsertTag(contestants, tagName)
	for i, player in pairs(contestants) do
		local Tag = Instance.new("StringValue")
		Tag.Name = tagName
		Tag.Parent = player
	end
end

local function toMS(s)
	return ("i:i"):format(s/60%60, s%60)
end

---------This is where it does not work (below)-----

function module.StartRound(length,piggy,chapterMap) -- length (in seconds)
	
	local outcome
	
	for i = length,0,-1 do
		
		if i == (length - 20) then
			module.TeleportPlayers({piggy},chapterMap.PlayerSpawns:GetChildren())
			status.Value = "Darkness has rised."
			wait(2)
		end
		
		local contestants = {}
		
		local isPiggyHere = false
		
		for i, player in pairs(game.Players:GetPlayers()) do
			
			if player:FindFirstChild("Contestant") then
				table.insert(contestants,player)
			elseif player:FindFirstChild("Piggy") then
				isPiggyHere = true
			end
			
		end
		
		if not isPiggyHere then -- if isPiggyHere == false / is the piggy dead / left the game?
			outcome = "darkness-faded"
			break
		end
		
		if #contestants == 0 then
			outcome = "darkness-took-everyone"
			break
		end
		
		if i == 0 then
			outcome = "time-up"
			break
		end
		
		status.Value = toMS(i)
		wait(1)
	end
	
	if outcome == "darkness-took-everyone" then
		status.Value = "Darkness Overtook Everyone"
	elseif outcome == "time-up" then
		status.Value = "Everyone Stands, No One Wins"
	elseif outcome == "darkness-faded" then
		status.Value = "Darkness Faded By Itself, Light Wins"
	end
	
	
	
	wait(5) -- Time that message stays
	
end

return module

1 comment

0

Rather than sending us a 140+ line script, put prints into it and run, then you can see where exactly it isn't running properly.

1 answer

ok i know why its error, its because in the function toMS(i) u put ("i:i") instead of "i:i" its because ("i:i") is not a string

ok so i fixed it

function toMS(s)
	return ("i:i"):format(s/60%60, s%60) -- ("i:i")
end

edit : idk why i cant say wat i can say, heres the example https://gyazo.com/dbd33ccb14de11d1a5063c9c62053f32

5 comments

0

but that part works like what i want to work, it is below the message i put

0

i dont see any errors at the below message. wat is the error?

0

i dont know, it just won't work

0

oh sorry dude that i cant help u :(

0

oh ok

This discussion is preserved as it was. New answers, comments, and votes are closed.