Well Im making this script that counts the candy then puts the value into the text. It works but I want to know how to make it work with multiple candy in a model with the same name so I dont have to assign hundreds of varibles like candy1 = game.Workspace.Candy1 ..etc . So basically I want to know how to make all the candy in the model able to add 1 to the value. Thanks This is the script in the brick.

candy = script.Parent
status = script.Status
textlabel = game.StarterGui.ScreenGui.TextLabel
db = false
candysound = game.Workspace.CandySound

function touched(plyr)
player = plyr.Parent:findFirstChild("Humanoid")
if player ~= nil and db == false then
	db = true
	wait()
	candysound:play()
	wait()
	status.Value = status.Value + 1
	wait()
	print("Wokring")
	wait(1)
	db = false
end	
end
 

This is script in gui..
candy = game.Workspace.Candy
status = candy.Script.Status
textlabel = script.Parent

status.Changed:connect(function(candy)
	textlabel.Text = "Candy Eaten: "..status.Value
end)



candy.Touched:connect(touched)

1 comment

0

You need to make more specific titles for your questions.