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

Why is the intValue in only one player working?

Asked by 6 years ago
Edited 6 years ago

I have my game set up so that all players get stringValues inside of them with the value "Linked", and for some reason whenever I do local servers or play with my friend on the server, only one character has the value "Linked." Why isn't this working?

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStorage")


--[[function TweenIncentive()
    for i, v in pairs(game.Players:GetPlayers()) do
        v.PlayerGui.PlayerScreenGui.LogInReward:TweenPosition(0, 600, 0, 0)
        wait(3)
        v.PlayerGui.PlayerScreenGui.LogInReward:TweenPosition(0, 2000, 0, 0)
        v.PlayerGui.PlayerScreenGui.LogInReward.Position = UDim2.new(0, -100, 0, 0)
    end
end]]
local StartingPoints = 500
local StartingLevel = 0
local DefaultSword = "Linked"
local Opening = script.OpeningScreen:Clone()

game.Players.PlayerAdded:connect(function(player)
    local key = "user_" .. player.userId

    Opening.Parent = player.PlayerGui

    game.Workspace.NumberIsInPlace.Value = game.Workspace.NumberIsInPlace.Value + 1



    --[[if player.Name == "JamaicaHolder" then
        player.Character.Humanoid.WalkSpeed = 30
        pl
    end]]

    local PlayerInf = Instance.new("Folder", player )
    PlayerInf.Name = "PlayerInfo"

    local stats = Instance.new("ObjectValue", player)
    stats.Name = "leaderstats" 

    local points = Instance.new("IntValue", PlayerInf)
    points.Name = "Player Points"

    local level = Instance.new("NumberValue", stats)
    level.Name = "Level"
    level.Value = "Linked"

    --[[if player.Name == "JamaicaHolder" then
        player:WaitForChild("Player Points").Value = 10000000000
    end]]

    local ingame = Instance.new("BoolValue", player)
    ingame.Name = "Ingame"


    local chosensword = Instance.new("StringValue", player)
    chosensword.Name = "PersonalSword"
    chosensword.Value = DefaultSword

    local thewins = Instance.new("IntValue", player)
    thewins.Name = "Wins"

    local streaknumber = Instance.new("IntValue", player)
    streaknumber.Name = "Streak"


    local GetSaved = DataStore:GetAsync(key)

    local Swords =  Instance.new("ObjectValue", player)
    Swords.Name = "Swords"

    local Items =  Instance.new("ObjectValue", player)
    Items.Name = "Items"


    local FreeLinked = Instance.new("BoolValue", Swords)
    FreeLinked.Name = "Linked"

    local IsInGame = Instance.new("BoolValue", player)
    IsInGame.Name = "GameBool"
    IsInGame.Value = true

    local trueGameBool = Instance.new("BoolValue", IsInGame)
    trueGameBool.Name = "trueIsInGameBool"

    local DarkHeartSword = player.Swords:FindFirstChild("DarkHeart")
    local FireBrandSword = player.Swords:FindFirstChild("FireBrand")
    local GhostWalkerSword = player.Swords:FindFirstChild("GhostWalker")
    local IlluminaSword = player.Swords:FindFirstChild("Illumina")
    local VenomShankSword = player.Swords:FindFirstChild("VenomShank")
    local WindForceSword = player.Swords:FindFirstChild("WindForce")
    local SmallLinkedSword = player.Swords:FindFirstChild("SmallLinked")
    local LargeLinkedSword = player.Swords:FindFirstChild("LargeLinked")
    local swords = player.Swords

    local SavedLevel = DataStore:GetAsync(player.userId..'Level')
    local SavedSword = DataStore:GetAsync(player.userId..'PersonalSword')

    if SavedLevel ~= nil then
        level.Value = SavedLevel
    end

    if SavedSword ~= nil then
        chosensword.Value = SavedSword
    end

    if GetSaved then
        points.Value = GetSaved[1]
        thewins.Value = GetSaved[2]
        chosensword.Value = GetSaved[3]
        streaknumber.Value = GetSaved[4]
        swords = GetSaved[14]
        if DarkHeartSword then
        DarkHeartSword.Value = GetSaved[5]
        end
        if FireBrandSword then
        FireBrandSword.Value = GetSaved[6]
        end
        if GhostWalkerSword then
        GhostWalkerSword.Value = GetSaved[7]
        end
        if IlluminaSword then
        IlluminaSword.Value = GetSaved[8]
        end
        if VenomShankSword then
        VenomShankSword.Value = GetSaved[9]
        end
        if WindForceSword then
        WindForceSword.Value = GetSaved[10]
        end
        if SmallLinkedSword then
        SmallLinkedSword.Value = GetSaved[11]
        end
        if LargeLinkedSword then
        LargeLinkedSword.Value = GetSaved[12]
        end
        if FreeLinked then
            FreeLinked.Value = GetSaved[13]
        end



        --[[if os.time()-time > 86400 then
            TweenIncentive()
        else
            --24 hours has not passed
        end]]


        --[[
        local SaveSwords = player.Swords:GetChildren()
    for i, v in pairs(SaveSwords) do
        local NumbersForSaving = {points.Value,
             thewins.Value,
             chosensword.Value,
             streaknumber.Value,
             SaveSwords

            }
        DataStore:SetAsync(key, NumbersForSaving)
        end]]
    end

    --[[if Time > 43200 then
        player.leaderstats.Streak.Value = player.leaderstats.Streak.Value + 1
        TweenIncentive()
    end]]

    player.Character.Humanoid.WalkSpeed = 0
    player.GameBool.trueIsInGameBool.Value = false

end)




game.Players.PlayerRemoving:connect(function(player)
    game.Workspace.NumberIsInPlace.Value = game.Workspace.NumberIsInPlace.Value - 1
    local key = player.userId

    local SaveSwords = player.Swords:GetChildren()
    local LevelValue = player.leaderstats.Level.Value
    local SwordValue = player.PersonalSword.Value

    DataStore:SetAsync(key..'-Level', LevelValue)
    DataStore:SetAsync(key..'-PersonalSword', SwordValue)

    for i, v in pairs(SaveSwords) do
    local Savetable = {
         player.PlayerInfo["Player Points"].Value,
         player.Wins.Value,
         player.PersonalSword.Value,
         player.Streak.Value,
         v.Value
        }
    DataStore:SetAsync(key, Savetable)
    end
end)


0
Could you add a script? User#21908 42 — 6y
0
Oh thx User#21908 42 — 6y
0
It's the "PersonalSword" part that isn't working. bigbenbennett 18 — 6y
0
what line is it on? Is there an error in studio? User#21908 42 — 6y
View all comments (8 more)
0
I have no idea if there is an error in studio, personal sword is on line 53 bigbenbennett 18 — 6y
0
play the game and check the output User#21908 42 — 6y
0
then tell me the output User#21908 42 — 6y
0
For player 1 and player 3, both have "linked" as the value but not player 2. But there's nothing wrong with the output. bigbenbennett 18 — 6y
0
hm User#21908 42 — 6y
0
try to not use deprecated methods User#21908 42 — 6y
0
I corrected the parents bigbenbennett 18 — 6y
0
This problem still persists bigbenbennett 18 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I noticed that you tried to put a string inside a number value on line forty:

local level = Instance.new("NumberValue", stats)
level.Name = "Level"
level.Value = "Linked"

also the second parameter of Instance.new is deprecated. You should set the parent like so:

local level = Instance.new("NumberValue")
level.Parent = stats
level.Name = "Level"
Ad

Answer this question