generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Why is string being expected?

Previous Thread :: Next Thread 
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 01:39 PM
local ValueType
if typeof(v)=="boolean" then
ValueType="BoolValue"
elseif typeof(v)=="number" then
ValueType="NumberValue"
end
local s=Instance.new(ValueType) ---- error refers to this
s.Name=v
s.Value=i
s.Parent=inven

14:37:47.625 - ServerScriptService.InventorySave:15: bad argument #1 to 'new' (string expected, got nil)


ATR'er since 2013.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
07 May 2017 01:41 PM
None of the if branches are being reached.


Report Abuse
Intern33t is not online. Intern33t
Joined: 19 Nov 2010
Total Posts: 1530
07 May 2017 01:42 PM
um

local s = Instance.new("ValueType")


hm
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 01:42 PM
What do you mean?


ATR'er since 2013.
Report Abuse
Intern33t is not online. Intern33t
Joined: 19 Nov 2010
Total Posts: 1530
07 May 2017 01:42 PM
wait ignore last

im an idiot
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 01:51 PM
@chim


ATR'er since 2013.
Report Abuse
textartotoboy2 is not online. textartotoboy2
Joined: 24 Jul 2012
Total Posts: 368
07 May 2017 01:51 PM
There's no such thing as "ValueType".
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 02:01 PM
@text
"local ValueType
if typeof(v)=="boolean" then
ValueType="BoolValue"
elseif typeof(v)=="number" then
ValueType="NumberValue"
end"


ATR'er since 2013.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
07 May 2017 02:04 PM
local ValueType
if typeof(v)=="boolean" then
ValueType="BoolValue"
elseif typeof(v)=="number" then
ValueType="NumberValue"
end


Neither the "ValueType="BoolValue"" part or the "ValueType="NumberValue"" part are being reached.

ValueType is nil.


Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 02:06 PM
so how would I fix that?


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 02:48 PM
bump


ATR'er since 2013.
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
07 May 2017 02:49 PM
Check if it isn't nil...

local ValueType
if typeof(v)=="boolean" then
ValueType="BoolValue"
elseif typeof(v)=="number" then
ValueType="NumberValue"
end
if ValueType then
local s=Instance.new(ValueType) ---- error refers to this
s.Name=v
s.Value=i
s.Parent=inven
end
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 02:52 PM
Now its not loading anything in


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 02:53 PM
full script:

local ds = game:GetService('DataStoreService'):GetDataStore('MoreItems')
local newtab = {}

game.Players.PlayerAdded:connect(function(player)
local pds = ds:GetAsync(player.UserId)
local inven = player:WaitForChild("Inventory")
for i,v in pairs(pds) do
local ValueType
if typeof(v)=="boolean" then
ValueType="BoolValue"
elseif typeof(v)=="number" then
ValueType="NumberValue"
end
if ValueType then
local s=Instance.new(ValueType)
s.Name=v
s.Value=i
s.Parent=inven
end
end
while player.Parent do
for i,v in pairs(inven:GetChildren()) do
if inven:FindFirstChild(v.Name) then
v.Value=inven[v.Name].Value
end
end
wait(1)
end
end)

game.Players.PlayerRemoving:connect(function(player)
local inven = player:WaitForChild("Inventory")
for i,v in pairs(inven:GetChildren()) do
table.insert(newtab, v.Name)
end
ds:SetAsync(player.UserId, newtab)
end)
game:BindToClose(function()
for _,player in pairs(game.Players:GetPlayers()) do
local inven = player:WaitForChild("Inventory")
for i,v in pairs(inven:GetChildren()) do
table.insert(newtab, v.Name)
end
ds:SetAsync(player.UserId, newtab)
end
end)


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 03:22 PM
bump


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 04:02 PM
bump


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
07 May 2017 04:49 PM
bump


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
08 May 2017 07:54 AM
bump


ATR'er since 2013.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
08 May 2017 08:33 AM
Try type instead of typeof.


Report Abuse
ChiefDays is not online. ChiefDays
Joined: 26 Sep 2016
Total Posts: 502
08 May 2017 08:44 AM
local ValueType
if typeof(v)=="boolean" then
ValueType="BoolValue"
elseif typeof(v)=="number" then
ValueType="NumberValue"
end
if ValueType then
local s=Instance.new(ValueType) ---- error refers to this
s.Name=v
s.Value=i
s.Parent=inven
else
warn("ValueType is nil because the index is a: "..typeof(v))
end




Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
08 May 2017 11:58 AM
still not working


ATR'er since 2013.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 May 2017 12:02 PM
If nothing is loading in then it is working properly. You had that error before because the type was neither a number nor a boolean and it still is neither a number nor a boolean.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
08 May 2017 12:02 PM
Its suppose to load in BoolValues and NumberValues only.


ATR'er since 2013.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 May 2017 12:04 PM
Exactly but v is neither.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
08 May 2017 12:05 PM
That's all that they can put into the folder though. I tested it, I put a BoolValue into the folder, and rejoined, it didn't load in the BoolValue.

The error is gone.


ATR'er since 2013.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image