I want to make a game that basically spams a bunch of parts. But after I reset the players leader stats parts, they won't go up again even if the player spawns more parts. Local Script for spawning parts :
-- Define Variables local UIS = game:GetService("UserInputService") local RepStore = game:GetService("ReplicatedStorage") local Spawning = RepStore:WaitForChild("Toggle") local player = game.Players.LocalPlayer local leaderstats = player:WaitForChild("leaderstats") local addParts = leaderstats:WaitForChild("Parts") local addPartEvent = RepStore:WaitForChild("AddPart") local ResetPartEvent = RepStore:WaitForChild("PartReset") local Parts = leaderstats:WaitForChild("Parts") -- Required Script local Folder = Instance.new("Folder",game.Workspace) Folder.Name = "SpawnedParts" Folder.ChildAdded:Connect(function() addPartEvent:FireServer(addParts) end) -- Start Script UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then print("E Key Pressed") Spawning.Value = true if Spawning.Value == true then print("Spawning Value is true") end while Spawning.Value == true do wait() local part = Instance.new("Part") part.Parent = game.Workspace:WaitForChild("SpawnedParts") end end end) -- Stop Script UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.Q then print("Q Key Pressed") Spawning.Value = false end end) -- Clear Script UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.C then print("C Key Pressed") local Folder = game.Workspace:FindFirstChild("SpawnedParts") Folder:Destroy() local Folder = Instance.new("Folder",game.Workspace) Folder.Name = "SpawnedParts" ResetPartEvent:FireServer(Parts) end end)
ServerScript =
-- Leader Stats Script game.Players.PlayerAdded:Connect(function(player) local LeaderStats = Instance.new("Folder",player) LeaderStats.Name = "leaderstats" local Parts = Instance.new("IntValue",LeaderStats) Parts.Name = "Parts" end) --End of Script -- Add Parts Script -- Define Variables local RepStore = game:GetService("ReplicatedStorage") local AddPart = RepStore:WaitForChild("AddPart") -- Main Script AddPart.OnServerEvent:Connect(function(player, addParts) addParts.Value = addParts.Value + 1 end) --End of Script -- Reset Parts Script local ResetParts = RepStore:WaitForChild("PartReset") ResetParts.OnServerEvent:Connect(function(player, addParts) addParts.Value = 0 end)