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

RaidEnd Script Not Working and Provides no errors in the error log/output?

I believe the problem may lie in the fact that the function is never called, or that it is embedded in a ChildAdded function, meaning it would only work in the instant that someone joined the game. I may just be overlooking this, but I'm exhausted.

p = {"player1","player2","player3"}

game.Players.ChildAdded:connect(function(newPlayer)
	if (newPlayer.Name ~= p) then
		return
	end
	newPlayer.Chatted:connect(function(msg)
		msg = msg:lower()
		if (msg == ":rend") then
			game.Workspace.Terminal.SoundWin:Play()
			local m = Instance.new("Message", game.Workspace)
			m.Text = ":// TCD HAS SUCCESSFULLY REPELLED THE INSURGENT THREAT. // RAID ID: "..math.floor(tick())
			wait(10)
			m:Destroy()
		end
	end)
end)

2 answers

✓ Accepted answer

On line 4, you're comparing the player's name to the table (p) itself; instead, I recommend using a dictionary and checking whether a player's in the list that way. An example of this would be:

local PlyrNamesInTable = {['TheeDeathCaster'] = true} -- An example of a dictionary; 'TheeDeathCaster' being the index, and 'true' being the value.

...
if PlyrNamesInTable[Player.Name] then -- We're checking whether the player's name matches (or finds(?) an index in the table; if not, it'll return `nil`, and if so, it'll return `true`.
	print(Player.Name..'\'s an admin.') -- If a player's an admin, it's print `PLAYER_NAME's an admin.`
end

Stuff Touched On But Never Really Explained

  1. Dictionaries - To quote the dev hub, "a dictionary stores a set of key/value pairs." In other words (please correct me if need be), we can set an index and a value in the table, like in the above code. (For more info, I recommend checking out the link.)

If you have any questions, please let me know. Have a good day. :)

Try

game.Players.PlayerAdded:Connect(function(newPlayer)

4 comments

0

Also change the other connect that's on line 7 to a capital C like Connect

0

No change.

0

Ok, well I don't think anyone uses ChildAdded much anymore so that's why I said that

0

Although it's a good suggestion to use PlayerAdded, "I don't think anyone uses ChildAdded much anymore" isn't the case; the event returns an actual player when they're added.

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