so guys, I have a save script, it works perfect.. vars and all are perfect but, in my replicated storage, i made a section where characters are. The characters name is why I made the script.
so far this is what i am trying to do, 2 scripts..
1 | local a = game.Players.LocalPlayer.SaveMonsters |
2 | if script.Parent.Name = = a:WaitForChild(script.Parent.Name) then |
3 | local b = a:WaitForChild(script.Parent.Name) |
4 | c = script.Parent:Clone(a.Value) |
5 | c.Parent = game.Workspace |
6 | end |
this is for the the item to match its int name...
then comes this to add value to my save script value
01 | while true do |
02 | wait() |
03 | if script.Parent.Parent = = game.Workspace then |
04 | if script.Parent.Name = = game.Players.LocalPlayer.SaveMonsters:WaitForChild(script.Parent.Name) then |
05 | a = game.Players.LocalPlayer.SaveMonsters:WaitForChild(script.Parent.Name) |
06 | a.Value = a.Value + 1 |
07 | script:Destroy() |
08 | end |
09 | end |
10 | if script.Parent.Parent = = game.Workspace.Monsters then |
11 | if script.Parent.Name = = game.Players.LocalPlayer.SaveMonsters:WaitForChild(script.Parent.Name) then |
12 | a = game.Players.LocalPlayer.SaveMonsters:WaitForChild(script.Parent.Name) |
13 | a.Value = a.Value + 1 |
14 | script:Destroy() |
15 | end |
16 | end |
17 | end |
with this I am suppose to make a monsters name from the replicated storage math its name found in the save script then clone the monster and place it in workspace. how would I do this? this is really hard i would LOVE some feedback, please help!
New script that is not working:
01 | function addMonstersToGameByPlayer (player, playerMonsters) |
02 | local tableOfMonstersRetrieved = playerMonsters:GetChildren() |
03 | for _, v in pairs (tableOfMonstersRetrieved) do |
04 | local potentialMatch = game.ReplicatedStorage.CharactersLevelOne:FindFirstChild(v.Name) |
05 | if potentialMatch then |
06 | for i = 1 , v.Value do |
07 | local c = potentialMatch:Clone() |
08 | c.Parent = game.Workspace |
09 | end |
10 | end |
11 | end |
12 | end |
I don't necessarily know how to fix your issue but doesn't this look like it needs to be fixed as shown?
1 | local a = game.Players.LocalPlayer.SaveMonsters |
2 | if script.Parent.Name = = a:WaitForChild(script.Parent.Name) then |
3 | local b = a:WaitForChild(script.Parent.Name) |
4 | local c = script.Parent:Clone(a.Value) -- if you haven't defined the c part shouldn't you define it with a local first as shown? |
5 | c.Parent = game.Workspace |
6 | end |