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

This Script works for two players then breaks...?

Asked by
L3xie 0
5 years ago

Okay so Basically I'm trying to store player data in a folder of values in the workspace to later Access for a variety of reasons. I.e parts with surface Gui's that will display characters names and Thumbnails. As I go along in scripting the game, I'm sure I will want to store many points of Player Data to access. However, this works if theirs only one or two players in the game, I need it to loop through 16 players without any repeats. I only have three in the script bc ill just write out the whole script for all 16 players. BUT I can't for the life of me figure it out! Any pointers? My scripting level is probably a -20 but I'm trying to learn as I go.

function SetWorkSpaceData() 
    local Spawnz = CurrentFurniture.HGStands.Spawns
    for i, v in pairs(game.Players:GetPlayers()) do
            if Spawnz.Spawn1.Toggle.Value == false then
            v.Character:SetPrimaryPartCFrame(CFrame.new(24.813, 9.717, -47.045))
            Spawnz.Spawn1.Toggle.Value = true
            game.Workspace.HGData.HG1.Player.Value = v.Name
            game.Workspace.HGData.HG1.Avatar.Value = v.UserId
            wait()
            else if Spawnz.Spawn1.Toggle.Value == true then
            v.Character:SetPrimaryPartCFrame(CFrame.new(22.978, 9.717, -44.424))
            Spawnz.Spawn2.Toggle.Value = true
            game.Workspace.HGData.HG2.Player.Value = v.Name
            game.Workspace.HGData.HG2.Avatar.Value = v.UserId
            wait()
            else if Spawnz.Spawn2.Toggle.Value == true then
            v.Character:SetPrimaryPartCFrame(CFrame.new(21.142, 9.717, -41.802))
            Spawnz.Spawn3.Toggle.Value = true
            game.Workspace.HGData.HG3.Player.Value = v.Name
            game.Workspace.HGData.HG3.Avatar.Value = v.UserId
            else if Spawnz.Spawn3.Toggle.Value == true then
            end
            end
            end
    end
end
0
Can you show me your entire script? Where do you call the function "SetWorkSpaceData()"? Pojoto 329 — 5y
0
SetWorkSpaceData() is inside of another function. And i use while true do to begin the list of functions. L3xie 0 — 5y

Answer this question