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

How would i make a Level Completion Script?

im working on a game that has levels with "Coins" and im trying to figure out how i would make a script that would check for all the "Coins" on the level to see if there all collected then Teleport them to the next level. Not sure if its a hard Script To make but any help would be apreciated :D

1 answer

The way i'd do it is make all the coins have bool values and set it to false by default. And when they are touched they go transparent and disable their collision.

local coin = script.Parent -- reference your coin here
local coinCollected = script.Parent.BoolValue -- check if the player collected the coin
local touched = false -- debounce

coin.Touched:Connect(function(hit) -- if the coin is touched
	
	if hit.Parent:FindFirstChild("Humanoid") then -- check if the thing that touched the coin is a player
		
	if touched == false then 
		touched = true -- activate debounce so you cant take the coin more than once
		
		coinCollected.Value = true 
	end
	
	end
	
end)

if coinCollected.Value == true then
	coin.Transparency = 1
	coin.CanCollide.Value = false -- if the player collected the coin then its invisible and cant collide with anything
	
	else
	
	touched = false -- reset the debounce
end

Next thing I'd do is make a script with a loop that checks for all BoolValues of the coins in the server and if they're all set to true then move to the next level and cframe them all there and reset their BoolValues, transparency, and collision.

1 comment

0

please help me on my post

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