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

script only adding one IntValue on player added?

Asked by
danglt 185
6 years ago

In my script it should create 18 different IntValues but its only creating "p11"?

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player)
 local folder = Instance.new("Folder",player)
 folder.Name = "places"


 local p11 = Instance.new("IntValue",folder)
 p11.Name = "p11"
 p11.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p11.Value)
 p11.Changed:connect(function()
  ds:SetAsync(player.UserId, p11.Value)
end)
local p12 = Instance.new("IntValue",folder)
 p12.Name = "p12"
 p12.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p12.Value)
 p12.Changed:connect(function()
  ds:SetAsync(player.UserId, p12.Value)
end)
local p13 = Instance.new("IntValue",folder)
 p13.Name = "p13"
 p13.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p13.Value)
 p13.Changed:connect(function()
  ds:SetAsync(player.UserId, p13.Value)
end)
local p14 = Instance.new("IntValue",folder)
 p14.Name = "p14"
 p14.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p14.Value)
 p14.Changed:connect(function()
  ds:SetAsync(player.UserId, p14.Value)
end)
local p15 = Instance.new("IntValue",folder)
 p15.Name = "p15"
 p15.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p15.Value)
 p15.Changed:connect(function()
  ds:SetAsync(player.UserId, p15.Value)
end)
local p16 = Instance.new("IntValue",folder)
 p16.Name = "p16"
 p16.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p16.Value)
 p16.Changed:connect(function()
  ds:SetAsync(player.UserId, p16.Value)
end)
local p17 = Instance.new("IntValue",folder)
 p17.Name = "p17"
 p17.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p17.Value)
 p17.Changed:connect(function()
  ds:SetAsync(player.UserId, p17.Value)
end)
local p18 = Instance.new("IntValue",folder)
 p18.Name = "p18"
 p18.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p18.Value)
 p18.Changed:connect(function()
  ds:SetAsync(player.UserId, p18.Value)
end)
local p19 = Instance.new("IntValue",folder)
 p19.Name = "p19"
 p19.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p19.Value)
 p19.Changed:connect(function()
  ds:SetAsync(player.UserId, p19.Value)
end)
local p21 = Instance.new("IntValue",folder)
 p21.Name = "p21"
 p21.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p21.Value)
 p21.Changed:connect(function()
  ds:SetAsync(player.UserId, p21.Value)
end)
local p22 = Instance.new("IntValue",folder)
 p22.Name = "p22"
 p22.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p22.Value)
 p22.Changed:connect(function()
  ds:SetAsync(player.UserId, p22.Value)
end)
local p23 = Instance.new("IntValue",folder)
 p23.Name = "p23"
 p23.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p23.Value)
 p23.Changed:connect(function()
  ds:SetAsync(player.UserId, p23.Value)
end)
local p24 = Instance.new("IntValue",folder)
 p24.Name = "p24"
 p24.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p24.Value)
 p24.Changed:connect(function()
  ds:SetAsync(player.UserId, p24.Value)
end)
local p25 = Instance.new("IntValue",folder)
 p25.Name = "p25"
 p25.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p25.Value)
 p25.Changed:connect(function()
  ds:SetAsync(player.UserId, p25.Value)
end)
local p26 = Instance.new("IntValue",folder)
 p26.Name = "p26"
 p26.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p26.Value)
 p26.Changed:connect(function()
  ds:SetAsync(player.UserId, p26.Value)
end)
local p27 = Instance.new("IntValue",folder)
 p27.Name = "p27"
 p27.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p27.Value)
 p27.Changed:connect(function()
  ds:SetAsync(player.UserId, p27.Value)
end)
local p28 = Instance.new("IntValue",folder)
 p28.Name = "p28"
 p28.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p28.Value)
 p28.Changed:connect(function()
  ds:SetAsync(player.UserId, p28.Value)
end)
local p29 = Instance.new("IntValue",folder)
 p29.Name = "p29"
 p29.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, p29.Value)
 p29.Changed:connect(function()
  ds:SetAsync(player.UserId, p29.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
 ds:SetAsync(player.UserId, player.places.p11.Value)
 ds:SetAsync(player.UserId, player.places.p12.Value)
 ds:SetAsync(player.UserId, player.places.p13.Value)
 ds:SetAsync(player.UserId, player.places.p14.Value)
 ds:SetAsync(player.UserId, player.places.p15.Value)
 ds:SetAsync(player.UserId, player.places.p16.Value)
 ds:SetAsync(player.UserId, player.places.p17.Value)
 ds:SetAsync(player.UserId, player.places.p18.Value)
 ds:SetAsync(player.UserId, player.places.p19.Value)
 ds:SetAsync(player.UserId, player.places.p21.Value)
 ds:SetAsync(player.UserId, player.places.p22.Value)
 ds:SetAsync(player.UserId, player.places.p23.Value)
 ds:SetAsync(player.UserId, player.places.p24.Value)
 ds:SetAsync(player.UserId, player.places.p25.Value)
 ds:SetAsync(player.UserId, player.places.p26.Value)
 ds:SetAsync(player.UserId, player.places.p27.Value)
 ds:SetAsync(player.UserId, player.places.p28.Value)
 ds:SetAsync(player.UserId, player.places.p29.Value)
end)
0
Script is inside ServerScriptService danglt 185 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
  1. why
  2. why 3. WHYYYY :( my eyes

try instancing all the IntValues and have their var names without numbers

then after instancing all of it you do var:GetPropertyChangedSignal("Value"):Connect(function() ds:SetAsync(player.UserId, var.Value) end)

then you do whatever eye breaking script u did like at the last ;(

0
I did as you said but now the variables come in one after another danglt 185 — 6y
0
That's what it supposed to do, do you know how a script functions? Scarperino 20 — 6y
Ad

Answer this question