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
COMMUNITY QUESTION
How would i make a Level Completion Script?
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
please help me on my post