CoinCollect system not working

I’m not totally sure if I did like anything right in these scripts, but nothing shows up in the output. I am asking for which module (i think that’s what it’s called) would make this work.

I was attempting to make an obby where you had to collect a (few) coin(s) to get to the next level. I made a small demo for myself before I started doing serious builds.

Screen Shot 2020-12-23 at 10.17.32 AM

Screen Shot 2020-12-23 at 10.17.27 AM

The green ball represents the coin. The green door represents the entry to the next level. The gray parts are representing the obby part. To start, I needed a system for the coin to go invisible when the player touches it. I also need a system for when the coin is collected for the door to open as well. I could probably figure out how to make the door go invisible if the coin is collected, however I do not know a module that can make the coin be collected.

I have tried the “Touched” module. That didn’t work, but maybe it was the way I wrote it out. I’m not good at ‘designing’ or ‘wording’ scripts so maybe that’s my problem.
Screen Shot 2020-12-23 at 10.26.21 AM

I can see that the ‘=’ sign is an error, but I don’t know how to fix it. Leave me some info in the replies please!

replace the ‘=’ sign with an ==

1 Like

You can do something like that:

local coin = script.Parent

coin.Touched:Connect(function()
  -- The function code
end)

documentation link can help you if you need

1 Like

TouchEnded is an event so I believe you can’t use boolean values on it.

Try this instead:

local coinCollected = script.Parent

coinCollected.Touched:Connect(function()
-- Change the transparency and turn collisions off to move to the next level.
end)
2 Likes
local coin = script.Parent
local door = -- put door here
coin.Touched:Connect(function()
--coin go bye bye
--door go bye bye
end)
1 Like

I’m testing out all of your solutions right now. Thanks for the help! I’ll leave a message once I’m done.

Same solution as @PercyGaming83.

Did you do it in a local script or in a script, it seems to me that in your case it must be done in a local script.

Yes I did do it in a local script actually. Let me fix that.

New error: When you launch the game the door and coin seem to already be removed (cancollide=false & transparency=1). Output says nothing is wrong.

Wait never mind it works now! I think one of the demo arrows wasn’t anchored and triggered the coin.

Solved! I made the game public so you can test it out: Obby - Roblox

For make a debounce:

local coin = script.Parent
local canTouch = true

coin.Touched:Connect(function()
  if canTouch then
    canTouch = false
    -- Function code ( transparency = 1 )
    wait(30)
     -- Function code ( transparency = 0 )
    canTouch = true
  end
end)

Do I add that to the script or delete what I have now and insert that (and fill the blanks)?

Edit: never mind it works now!