Script Doesnt Change Leaderboard Stats?
Asked by
2 years ago Edited 2 years ago
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
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | local leaderstats = Instance.new( "Folder" ) |
03 | leaderstats.Name = ( "leaderstats" ) |
04 | leaderstats.Parent = player |
06 | local cash = Instance.new( "IntValue" ) |
08 | cash.Parent = leaderstats |
Normal Legacy Script In Button in Workspace, the ball maker
01 | script.Parent.ClickDetector.MouseClick:connect( function (player) |
02 | local clone = Instance.new( "Part" ) |
04 | clone.Material = Enum.Material.SmoothPlastic |
05 | clone.Shape = Enum.PartType.Ball |
06 | clone.Position = Vector 3. new(- 81.973 , 148.927 , - 24.005 ) |
07 | clone.Anchored = false |
08 | clone.Color = Color 3. fromRGB(math.random( 0 , 255 ),math.random( 0 , 255 ),math.random( 0 , 255 )) |
09 | clone.Size = Vector 3. new( 1.3 , 1.3 , 1.3 ) |
10 | clone.CanCollide = true |
11 | local cloneOutline = clone:Clone() |
12 | cloneOutline.Anchored = false |
13 | cloneOutline.Size = Vector 3. new( 1.5 , 1.5 , 1.5 ) |
14 | cloneOutline.Transparency = 0.75 |
15 | cloneOutline.Name = "Outline" |
16 | cloneOutline.CanCollide = false |
17 | local model = Instance.new( "Model" ) |
18 | model.Parent = workspace.ExistingBalls |
19 | model.Name = "BallModel" |
21 | cloneOutline.Parent = model |
22 | local weld = script.Weld:Clone() |
25 | local destroy = script.DestroyScript:Clone() |
26 | destroy.Parent = clone |
27 | destroy.Enabled = true |
28 | local playername = Instance.new( "StringValue" ) |
29 | playername.Name = "PlayerName" |
30 | playername.Value = tostring (player) |
31 | playername.Parent = model |
32 | local money = player.leaderstats.Money |
Two Normal Legacy Script In Above Script In Button in Workspace (gets cloned to each ball)
1 | script.Parent.Touched:Connect( function (hit) |
2 | if hit.Name = = "Destroy" then |
3 | script.Parent.Parent:Destroy() |
4 | local player = game.Players.LocalPlayer |
5 | if player.leaderstats.Money.Value = = script.Parent.Parent.PlayerName.Value then |
6 | player.leaderstats.Money.Value + = 1 |
03 | local function scan(parent) |
04 | for _,v in pairs (parent:GetChildren()) do |
05 | if (v:IsA( "BasePart" )) then |
07 | local w = Instance.new( "Weld" ) |
08 | w.Name = ( "%s_Weld" ):format(v.Name) |
09 | w.Part 0 ,w.Part 1 = last,v |
10 | w.C 0 = last.CFrame:inverse() |
11 | w.C 1 = v.CFrame:inverse() |
21 | for _,v in pairs (parts) do |