You have made a folder in the ServerScriptService, in which the value of the resources are stored. Good idea, but did you make one folder per player??? If so, then I only have an idea to solve it that you may not like. It's easier to make the folder in the player and not in the ServerScriptService, as if you were doing a leaderstats:
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | local FolderName = Instance.new( "Folder" , player) |
03 | FolderName.Name = player.Name |
04 | local Coal = Instance.new( "IntValue" , FolderName) |
06 | local Copper = Instance.new( "IntValue" ,FolderName) |
08 | local Iron = Instance.new( "IntValue" , FolderName) |
10 | local Tin = Instance.new( "IntValue" , FolderName) |
12 | local Gold = Instance.new( "IntValue" , FolderName) |
14 | local Clay = Instance.new( "IntValue" , FolderName) |
16 | local Rock = Instance.new( "IntValue" , FolderName) |
So, I tried it myself and it works, your code should be like this (don't forget my code):
001 | game.ReplicatedStorage.Oof.OnServerEvent:Connect( function (player) |
003 | local FolderName = Instance.new( "Folder" , player) |
004 | FolderName.Name = player.Name |
005 | local Coal = Instance.new( "IntValue" , FolderName) |
007 | local Copper = Instance.new( "IntValue" ,FolderName) |
008 | Copper.Name = "Copper" |
009 | local Iron = Instance.new( "IntValue" , FolderName) |
011 | local Tin = Instance.new( "IntValue" , FolderName) |
013 | local Gold = Instance.new( "IntValue" , FolderName) |
015 | local Clay = Instance.new( "IntValue" , FolderName) |
017 | local Rock = Instance.new( "IntValue" , FolderName) |
020 | local playersname = player.Name |
021 | local FolderName = player:FindFirstChild(playersname) |
024 | if script.Parent.InUse.Value = = false then |
025 | script.Parent.InUse.Value = true |
026 | local kickAnimation = Instance.new( "Animation" ) |
028 | local kickAnimationTrack = player.Character.Humanoid:LoadAnimation(kickAnimation) |
029 | kickAnimationTrack:Play() |
031 | script.Parent.InUse.Value = false |
040 | local function Kill (hit) |
043 | if hit.Parent.Name = = "Rock" and script.Parent.Debounce.Value = = false and script.Parent.InUse.Value = = true then |
044 | script.Parent.Debounce.Value = true |
045 | FolderName.Stone.Value = FolderName.Stone.Value + 1 |
046 | player.PlayerGui.Inventory.Main.Frame.Items.Stone.TextButton.Text = "Stone: " .. FolderName.Stone.Value |
047 | A = game.ServerScriptService.Notify |
049 | B.Value.Value = "Rock + 1" |
050 | B.Parent = player.PlayerGui |
051 | hit.Parent.Damage.Value = hit.Parent.Damage.Value + 1 |
056 | script.Parent.Debounce.Value = false |
057 | print (script.Parent.Debounce.Value) |
060 | if hit.Parent.Name = = "Copper" and script.Parent.Debounce.Value = = false and script.Parent.InUse.Value = = true then |
061 | script.Parent.Debounce.Value = true |
062 | FolderName.Copper.Value = FolderName.Copper.Value + 1 |
063 | player.PlayerGui.Inventory.Main.Frame.Items.Copper.TextButton.Text = "Copper: " .. FolderName.Copper.Value |
064 | A = game.ServerScriptService.Notify |
066 | B.Value.Value = "Copper + 1" |
067 | B.Parent = player.PlayerGui |
068 | hit.Parent.Damage.Value = hit.Parent.Damage.Value + 1 |
071 | script.Parent.Debounce.Value = false |
072 | print (script.Parent.Debounce.Value) |
077 | if hit.Parent.Name = = "Tin" and script.Parent.Debounce.Value = = false and script.Parent.InUse.Value = = true then |
078 | script.Parent.Debounce.Value = true |
079 | FolderName.Tin.Value = FolderName.Tin.Value + 1 |
080 | player.PlayerGui.Inventory.Main.Frame.Items.Tin.TextButton.Text = "Tin: " .. FolderName.Tin.Value |
081 | A = game.ServerScriptService.Notify |
083 | B.Value.Value = "Tin + 1" |
084 | B.Parent = player.PlayerGui |
085 | hit.Parent.Damage.Value = hit.Parent.Damage.Value + 1 |
088 | script.Parent.Debounce.Value = false |
090 | print (script.Parent.Debounce.Value) |
094 | if hit.Parent.Name = = "Gold" and script.Parent.Debounce.Value = = false and script.Parent.InUse.Value = = true then |
095 | script.Parent.Debounce.Value = true |
096 | FolderName.Gold.Value = FolderName.Gold.Value + 1 |
097 | player.PlayerGui.Inventory.Main.Frame.Items.Gold.TextButton.Text = "Gold: " .. FolderName.Gold.Value |
098 | A = game.ServerScriptService.Notify |
100 | B.Value.Value = "Gold + 1" |
101 | B.Parent = player.PlayerGui |
102 | hit.Parent.Damage.Value = hit.Parent.Damage.Value + 1 |
106 | script.Parent.Debounce.Value = false |
107 | print (script.Parent.Debounce.Value) |
111 | if hit.Parent.Name = = "Iron" and script.Parent.Debounce.Value = = false and script.Parent.InUse.Value = = true then |
112 | script.Parent.Debounce.Value = true |
113 | FolderName.Iron.Value = FolderName.Iron.Value + 1 |
114 | player.PlayerGui.Inventory.Main.Frame.Items.Iron.TextButton.Text = "Iron: " .. FolderName.Iron.Value |
115 | A = game.ServerScriptService.Notify |
117 | B.Value.Value = "Iron + 1" |
118 | B.Parent = player.PlayerGui |
119 | hit.Parent.Damage.Value = hit.Parent.Damage.Value + 1 |
123 | script.Parent.Debounce.Value = false |
124 | print (script.Parent.Debounce.Value) |
129 | if hit.Parent.Name = = "Clay" and script.Parent.Debounce.Value = = false and script.Parent.InUse.Value = = true then |
130 | script.Parent.Debounce.Value = true |
131 | FolderName.Clay.Value = FolderName.Clay.Value + 1 |
132 | player.PlayerGui.Inventory.Main.Frame.Items.Clay.TextButton.Text = "Clay: " .. FolderName.Clay.Value |
133 | A = game.ServerScriptService.Notify |
135 | B.Value.Value = "Clay + 1" |
136 | B.Parent = player.PlayerGui |
137 | hit.Parent.Damage.Value = hit.Parent.Damage.Value + 1 |
141 | script.Parent.Debounce.Value = false |
142 | print (script.Parent.Debounce.Value) |
146 | if hit.Parent.Name = = "Coal" and script.Parent.Debounce.Value = = false and script.Parent.InUse.Value = = true then |
147 | script.Parent.Debounce.Value = true |
148 | FolderName.Coal.Value = FolderName.Coal.Value + 1 |
149 | player.PlayerGui.Inventory.Main.Frame.Items.Coal.TextButton.Text = "Coal: " .. FolderName.Coal.Value |
150 | A = game.ServerScriptService.Notify |
152 | B.Value.Value = "Coal + 1" |
153 | B.Parent = player.PlayerGui |
154 | hit.Parent.Damage.Value = hit.Parent.Damage.Value + 1 |
158 | script.Parent.Debounce.Value = false |
159 | print (script.Parent.Debounce.Value) |
166 | script.Parent.Handle.Touched:Connect(Kill) |