so im making a game that when you press a part / button, it creates a part, turns the shape into a ball, turns it into a random color, clones it, make it bigger and a bit transparent, makes a model, clones 2 of the children scripts and parents them to the main ball part and welds everything, also makes a stringvalue that has the players name in it (the one who spawned that ball), and a script that when it touches a part names destroy, it destroys the ball and adds to the players money, but for some reason that script doesn't change the leaderboard, can anyone help
Normal Legacy Script In ServerScriptService, the leaderboard
game.Players.PlayerAdded:Connect(function(player) local leaderstats= Instance.new("Folder") leaderstats.Name= ("leaderstats") leaderstats.Parent= player local cash= Instance.new("IntValue") cash.Name= ("Money") cash.Parent = leaderstats cash.Value = 0 end)
Normal Legacy Script In Button in Workspace, the ball maker
script.Parent.ClickDetector.MouseClick:connect(function(player) local clone = Instance.new("Part") clone.Name = "Ball" clone.Material = Enum.Material.SmoothPlastic clone.Shape = Enum.PartType.Ball clone.Position = Vector3.new(-81.973, 148.927, -24.005) clone.Anchored = false clone.Color = Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255)) clone.Size = Vector3.new(1.3,1.3,1.3) clone.CanCollide = true local cloneOutline = clone:Clone() cloneOutline.Anchored = false cloneOutline.Size = Vector3.new(1.5,1.5,1.5) cloneOutline.Transparency = 0.75 cloneOutline.Name = "Outline" cloneOutline.CanCollide = false local model = Instance.new("Model") model.Parent = workspace.ExistingBalls model.Name = "BallModel" clone.Parent = model cloneOutline.Parent = model local weld = script.Weld:Clone() weld.Parent = model weld.Enabled = true local destroy = script.DestroyScript:Clone() destroy.Parent = clone destroy.Enabled = true local playername = Instance.new("StringValue") playername.Name = "PlayerName" playername.Value = tostring(player) playername.Parent = model local money = player.leaderstats.Money end)
Two Normal Legacy Script In Above Script In Button in Workspace (gets cloned to each ball)
script.Parent.Touched:Connect(function(hit) -- checks what the ball part clone has touched if hit.Name == "Destroy" then -- checks if the part it touched is named destroy script.Parent.Parent:Destroy() -- destroys the ball clone model local player = game.Players.LocalPlayer if player.leaderstats.Money.Value == script.Parent.Parent.PlayerName.Value then player.leaderstats.Money.Value += 1 end end end)
function weld() local parts,last = {} local function scan(parent) for _,v in pairs(parent:GetChildren()) do if (v:IsA("BasePart")) then if (last) then local w = Instance.new("Weld") w.Name = ("%s_Weld"):format(v.Name) w.Part0,w.Part1 = last,v w.C0 = last.CFrame:inverse() w.C1 = v.CFrame:inverse() w.Parent = last end last = v table.insert(parts,v) end scan(v) end end scan(script.Parent) for _,v in pairs(parts) do v.Anchored = false end end weld() script:Remove()