Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When the button is clicked, it doesn't function at all?

The issue is, the thing wont even function at all when i click it. Basically what i'm trying to make is a "Contest" system. If you click the button, it will put your username in the table and change the "Participants:" text and will add your username in it too. It doesn't send errors or anything, it just doesn't function. Please fix, would be appreciated.

local ParticipantSign = game.Workspace.Participants.SurfaceGui.Text
local DatastoreService = game:GetService("DataStoreService")

local Participants = DatastoreService:GetDataStore("Participants")
local ParticipantsTable = {}

function OnClicked(player)
	for i, v in pairs(ParticipantsTable) do
		if v == player.Name then
			print(ParticipantsTable.." nah you're in it")
			return
		else
			Participants:GetAsync(player.Name)
			table.insert(ParticipantsTable, player.Name)
			print(ParticipantsTable.. " yes it worked")
			ParticipantSign.Text = ParticipantSign.Text..player.Name..", "
		end
	end
end

script.Parent.ClickDetector.MouseClick:Connect(OnClicked)

1 comment

0

update: in line 14 even if i put table.insert(ParticipantsTable, player.Name), the button will still not function.

1 answer

✓ Accepted answer

On line 14, you are using table.insert without providing the table for it. Change it to this and it should work:

table.insert(ParticipantsTable, player.Name)

9 comments

0

the button still isn't functioning.

0

Does it print of any statements you put?

0

no. not even printing works

0

One question, why do you need a datastore for this? What's the point of it?

0

it's not for 1 server, its for all servers. thats why there's a datastore.

0

plus im kinda a beginner, so i dont know that much about scripting.

0

In that case, i would recommand messing sevice. Check it out here https://developer.roblox.com/en-us/api-reference/class/MessagingService

0

this might help. thanks

0

Nps

This discussion is preserved as it was. New answers, comments, and votes are closed.