Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i make a Level Completion Script? [closed]

Asked by
linx45 -1
6 years ago

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

Closed as Not Constructive by GingeyLol, Le_Teapots, Leamir, Vulkarin, and BlueTaslem

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 6 years ago

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.

0
please help me on my post dareveloper 9 — 6y
Ad