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

player parameter without player added function?

Asked by 4 years ago
Edited by royaltoe 4 years ago

Code:

local x = game:GetService("TweenService")

local gv = Instance.new("BoolValue", game.ReplicatedStorage)
gv.Value = false -- open

local validRanks = {"Developer", "Phoenix Guard", "Peacekeeper", "Council Members","Phoenix Council Members",  "Cardinal Witch/Warlock","Majestic Being" }

function playerIsValidRank(player)
    local playerRank = player:GetRoleInGroup(5527515)

    for _, rank in pairs(validRanks)do
        if playerRank  == rank then
            return true
        end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    print(playerRank)

    local wplayer = game.Workspace:WaitForChild(player.Name)

    player.Chatted:Connect(function(message)
        local foundMessage = string.find(message:lower(), "colloportus") 

        if  foundMessage  and playerIsValidRank(player) then
                gv.Value = false
                local gate = game.Workspace.Gate

                for i,v in pairs(gate:GetChildren()) do

                    local m = {Position = Vector3.new(v.Position.X, v.Position.Y+29, v.Position.Z)}
                    local t = x:Create(v, TweenInfo.new(3.2, Enum.EasingStyle.Sine,     Enum.EasingDirection.InOut, 0, false, 0), m)
                    t:Play()
                end
            end
        end
    end)
end)

game.Players.PlayerAdded:Connect(function(player)
    local playerrank = player:GetRoleInGroup(5527515)
    print(playerrank)
    local wplayer = game.Workspace:WaitForChild(player.Name)

    player.Chatted:Connect(function(message)
        local foundMessage = string.find(message:lower(), "alohomora") 

        if  foundMessage  and playerIsValidRank(player) then
            if gv.Value == false then 
                gv.Value = true 
                local gate = game.Workspace.Gate

                for i,v in pairs(gate:GetChildren()) do

                    local m = {Position = Vector3.new(v.Position.X, v.Position.Y-29, v.Position.Z)}
                    local t = x:Create(v, TweenInfo.new(3.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), m)
                    t:Play()
                end
            end
        end
    end)
end)

Basically, if 1 person joins, it works, but if 2 people join, it breaks i need the player parameter without playeradded,playerleft

0
Uh, please check that I had a bit of confused that your description thing. Xapelize 2658 — 4y
0
Put the or statements in parenthesis. DeceptiveCaster 3761 — 4y
0
Thank you royaltoe, but since I want to LEARN this, please explain what message:lower() does, thank you! AcrylixDev 119 — 4y
0
Royaltoe, there was one problem with the formatting (which i fixed) but if another player joins and says ANYTHING that meets the ranks it will go down, how can I fix that? AcrylixDev 119 — 4y
View all comments (3 more)
0
your script up a bit. message:lower() converts whatever the player says to lowercase and string.find() sees if the text colloportus is in the string. it needs to be lower case since caps matter. royaltoe 5144 — 4y
0
ill edit your code to have the correct answer because i don't want to write a full answer to the post unless i fully know its solved. royaltoe 5144 — 4y
0
edited comment. please let me know if you need more help by messaging me on discord. i don't check here often. Here's my discord: Lucy#0003 royaltoe 5144 — 4y

Answer this question