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

I keep getting Errors while making Vote Pads, can someone please help me? [closed]

Asked by 6 years ago

So I am trying to script Voting Pads so that players can vote for different maps.

ERRORS that I am getting:

21:30:32.346 - GameName_Secondary is not a valid member of Folder 21:30:32.347 - Stack Begin 21:30:32.348 - Script 'ServerScriptService.IntroGui_One.IntroGui.MainFrame.Intro.gametitle.text2.MainTL.tl_update', Line 7 21:30:32.348 - Stack End 21:30:32.350 - CreatorName_Secondary is not a valid member of Folder 21:30:32.351 - Stack Begin 21:30:32.351 - Script 'ServerScriptService.IntroGui_One.IntroGui.MainFrame.Intro.presents.text2.MainTL.tl_update', Line 7 21:30:32.351 - Stack End 21:30:32.648 - GameName_Secondary is not a valid member of Folder 21:30:32.648 - Stack Begin 21:30:32.649 - Script 'ServerScriptService.IntroGui_One.IntroGui.MainFrame.Intro.gametitle.text2.MainTL.mtl_anim', Line 5 21:30:32.649 - Stack End 21:30:32.676 - CreatorName_Secondary is not a valid member of Folder 21:30:32.677 - Stack Begin 21:30:32.677 - Script 'Players.diablotoken.PlayerGui.IntroGui.MainFrame.Intro.presents.text2.MainTL.tl_update', Line 7 21:30:32.677 - Stack End 21:30:32.678 - GameName_Secondary is not a valid member of Folder 21:30:32.678 - Stack Begin 21:30:32.678 - Script 'Players.diablotoken.PlayerGui.IntroGui.MainFrame.Intro.gametitle.text2.MainTL.tl_update', Line 7 21:30:32.679 - Stack End 21:30:32.873 - GameName_Secondary is not a valid member of Folder 21:30:32.880 - Stack Begin 21:30:32.880 - Script 'Players.diablotoken.PlayerGui.IntroGui.MainFrame.Intro.gametitle.text2.MainTL.mtl_anim', Line 5 21:30:32.880 - Stack End 21:30:33.343 - Players.diablotoken.PlayerGui.Client:2: '<name>' expected near '.'

Server Side Script:

--Assets
local rep = game.ReplicatedStorage
local assets = rep.Assets

--Maps
local maps = assets.Maps

--Signals
local signals = assets.Signals
local event = signals.Event
local FEvent = signals.FEvent

--Static Variables
local mapVotes = {}

--Game Variables
local Game = workspace.Game
local stats = Game.Stats
local settings = {
        mapVoteTime=15;
        mapVoteDelay=3;
        playersRequired=1;
}

--Primary Events

--[[
    ARRAY = mapVotes
        MapArray
            Id
            mapName
            players
                player=UserId
--]]

event.OnServerEvent:connect(function(variables)
    if variables.reason == "voteOnMap" then
    --First check if a player already voted for a map, if so change vote.
        for a,b in pairs(mapVotes) do
            for d,c in pairs(b.players) do
                if c.player == player.UserId then
                    table.remove(b.players, d)
                    break
                end
            end
        end
        --Add player to the map votes.
        for a,b in pairs(mapVotes) do
            if b.id == variables.itemNum then
                table.insert(b)
            end
        end
    elseif variables.reason == "removeFromVote" then
        for a,b in pairs(mapVotes) do
            for d,c in pairs(b.players) do
                if c.player == playerUserId then
                    table.remove(b.players, d)
                    break
                end
            end
        end
    end
end)

function getMap()
    local randomMap = maps:GetChildren()[math.random(1,#maps:GetChildren())]
    for a,b in pairs(mapVotes) do
        if b.mapName == randomMap.Name then
            return getMap()
        end
    end
    return randomMap.Name
end

while wait() do
    if #game.Players:GetPlayers() < settings.playersRequired then
        local playersNeeded = settings.playersRequired-#game.Players:GetPlayers()
        stats.Status.Value = playersNeeded.." "..((playersNeeded==1 and "Player") or "Players").." needed to play!"
    else
        --Assign maps
        mapVotes={}
        for a,b in pairs(Game.Special.VotingPads:GetChildren()) do
            table.insert(mapVotes, {id=tonumber(b.Name:match("%d+")); mapName=getMap(); players={};})
        end

        --Fire Clients, start sending in votes.
        event:FireAllClients({reason="startVoting"})

        --Do main loop
        local start = tick()
        while wait() do
            if tick()-start >= settings.mapVoteTime then break end
            local secondsLeft = math.floor(settings.mapVoteTime-(tick()-start))
            stats.Status.Value = secondsLeft.." "..((secondsLeft==1 and "Second") or "Seconds").." Left to Vote!"
            for a,b in pairs(Game.Special.VotingPads:GetChildren()) do
                local platersVoting, mName
                for d,c in pairs(mapVotes) do
                    if c.id == tonumber(b.Name:match("%d+")) then
                        playersVoting=#c.players
                        mName=c.mapName
                        break
                    end
                end
                b.sGui.Title.Text = mName.." - "..playersVoting.." "..((playersVoting==1 and "Voter") or "Voters")
            end
        end

        --Get Winner
        table.sort(mapVotes, function(a,b) return #a.players>#b.players end)

        for a,b in pairs(Game.Special.VotingPads:GetChildren()) do
            if tonumber(b.Name:match("%d+")) == mapVotes[1].id then
                b.sGui.Title.Text = "Winner!"
                stats.Status.Value = mapVotes[1].mapName.." was chosen!"
            else
                b.sGui.Title.Text = "Lost Vote!"
            end
        end

        wait(settings.mapVoteDelay)
    end
end

Client Side Script:

--Player
local.player = game.players.localplayers
local char = player.character or CharacterAdded:Wait()
local gui = WaitForChild("PlayerGui")
ui = gui:WaitForChild("ui")

--Assets
local rep = game.ReplicatedStorage
local assets = rep.Assets

--Maps
local maps = assets.Maps

--Signals
local signals = assets.Signals
local event = signals.Event
local FEvent = signals.FEvent

--Game Variables
local game = workspace.Game
local stats = Game.Stats

--Static variables
local vars = {
 currentVote=nil
 services={}:
}

--Primary Events
event.OnClientEvent:connect(function(variables)
    if variables.reason == "startVoting" then
        table.insert(vars.services, game("GetService","RunService").RenderStepped:connect(function()
            local ray = Ray.new(char.PrimaryPart.CFrame.p, Vector3.new(0,-1000,0))
            local object = workspace:FindPartOnRay(ray, char, false, false)
            if object and object.Name:match("VotingPad") then
                local votingPadNum = tonumber(object.Name:match("%d+"))
                if vars.currentVote==nil then
                    vars.currentVote = votingPadNum
                    event:FireServer({reason="voteOnMap"; itemNum=votingPadNum;})
                elseif vars.currentVote~=votingPadNum then
                    vars.currentVote = votingPadNum
                    event:FireServer({reason="voteOnMap"; itemNum=votingPadNum;})
                end
            elseif vars.currentVote~=nil then
                vars.currentVote=nil
                event:FireServer({reason="removeFromVote"})
            end
        end))
    elseif variables.reason == "endVoting" then
        for a,b and pairs(vars.services) do
            b:disconnect()
        end
        vars.services={}
    end
end)

--Initiate Title Updater
game("GetService"."RunService").RennerStepped:connect(function()
    ui:WaitForChild("Title").Text = stats.Status.Value
end)
0
you have : on line 26 ? can you check the syntax User#5423 17 — 6y
0
^ User#21908 42 — 6y

Closed as Too Broad by Goulstem

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?