Need help with a trick or treat system

Hey guys. im learning how to become an advanced scripter. would anyone mind helping me out?

So… im working on making new things and trying things out. but, i have ran into a problem. i have no idea how to make this click detector give my currency"Candy" whenever the door is clicked. and also show my popup gui. plus, id like it to be a random amount of robux. here of some screen shots of my progress!


2 Likes

Have you tried leaderstats? This is what I’d recommend!

yes, leaderstats are done. but… i can’t make the door give my currency" Candy Corn" when clicked and also show the popupgui.

well, you don’t need to put function into while loops.(this is updated door script)

script.Parent.ClickDetector.MouseClick:Connect(function(player) --function will run whenever player clicks the door, and it even detects which player clicked it
   local gui = player:WaitForChild("PlayerGui") -- variables will make script shorter
   local popupGui = gui:WaitForChild("PopUpGui")
   
   popupGui.PopUpText.CandyCorn.Value = popupGui.PopUpText.CandyCorn.Value + 3 -- every click will add some candy corns

end)

if you want to make it show how much candy you have on gui, you can try this

--put this in PopUpText
while wait(0.1) do
    script.Parent.Text = script.Parent.CandyCorn.Value
end
2 Likes

You can change it instead to this:

script.Parent.CandyCorn.Changed:Connect(function()
      script.Parent.Text = script.Parent.CandyCorn.Value
end)
2 Likes

thanks for the reply. appreciate it!

1 Like

appreciate the reply! thank you

1 Like

No problem! Good luck with your project :slight_smile: