Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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. :)

Ad
Log in to vote
0
Answered by 6 years ago

Try

game.Players.PlayerAdded:Connect(function(newPlayer)
0
Also change the other connect that's on line 7 to a capital C like Connect TheEpicObbyCreator 32 — 6y
0
No change. FortunaAdmin 19 — 6y
0
Ok, well I don't think anyone uses ChildAdded much anymore so that's why I said that TheEpicObbyCreator 32 — 6y
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. TheeDeathCaster 2368 — 6y

Answer this question