Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get the rebirth system to multiply stat when a player has rebirthed?

Asked by 3 years ago

This script in a part in a model in workspace, gives me the error of, leaderstats is nil in player, even when I do in face have leaderstats, and a rebirth.

Line 19 is how the image changes, and when player has a rebirth, it should skip an image, and skip by how many rebirths they have. If you're wondering about the + 1 at the end, thats so 1 x 1 doesnt happen, because the first rebirth would have been useless.

local last = 42
db = false
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if db == false then
            db = true
            player.leaderstats.Changes.Value = player.leaderstats.Changes.Value + 1
            script.Parent.Decal.Texture = "rbxassetid://5649009978"
            local name = {
                [1] = "Zebra Streamer";[2] = "65 Wat Meme";[3] = "Hi color line";[4] = "Cresendo";[5] = "Gravity Coil";[6] = "Galaxy";[7] = "Third Eye";[8] = "Ed Sheeran";[9] = "Wrong Game, Buddy.";[10] = "Jupiter";[11] = "WHAT IS WRONG WITH YOU";[12] = "This seems familar...";[13] = "O_O OMG GUN";[14] = "E";[15] = "Didn't this already happen?";[16] = "blank";[17] = "stonks working";[18] = "Such love";[19] = "Deja Vu";[20] = "Dominus";[21] = "Rainbow Cat Tail";[22] = "ninja";[23] = "space unicorn";[24] = "pattern";[25] = "roblox game";[26] = "JOIN DHAR MANISM NOW";[27] = "Ok, that's it right?";[28] = "Behind the scenes";[29] = "Right game, buddy";[30] = "Idk, Something";[31] = "Jibber Jabber";[32] = "Mushroom";[33] = "Scribble";[34] = "Uno Reverse";[35] = "Handshake";[36] = "dead computer";[37] = "tiky";[38] = "totally an image";[39] = "shaggy";[40] = "jak da god";[41] = "derpy noob";[42] = "tree"
            }


            local picId = {
                [1] = "rbxassetid://3069716876"; [2] = "rbxassetid://5651929240"; [3] = "rbxassetid://4780891"; [4] = "rbxassetid://578136722"; [5] = "rbxassetid://23534054"; [6] = "rbxassetid://6870516399"; [7] = "rbxassetid://153167250"; [8] = "rbxassetid://120417897"; [9] = "rbxassetid://5038853224"; [10] = "rbxassetid://6396160512"; [11] = "rbxassetid://2483112"; [12] = "rbxassetid://6870685325"; [13] = "rbxassetid://205751358"; [14] = "rbxassetid://6870699252"; [15] = 'rbxassetid://6870701444'; [16] = "rbxassetid://6870705295"; [17] = "rbxassetid://6870708256"; [18] = "rbxassetid://6870713220";[19] = "rbxassetid://6870720448";[20] = "rbxassetid://5363950339";[21] = "rbxassetid://469008770";[22] = "rbxassetid://44254536";[23] = "rbxassetid://692827210";[24] = "rbxassetid://1305232966";[25] = "rbxassetid://6872338795";[26] = "rbxassetid://6872366648";[27] = "rbxassetid://6872368292";[28] = "rbxassetid://6872376461";[29] = "rbxassetid://6872381827";[30] = "rbxassetid://5109122581";[31] = "rbxassetid://6873146656";[32] = "rbxassetid://6873329125";[33] = "rbxassetid://6873498573";[34] = "rbxassetid://6874546430";[35] = "rbxassetid://5124191428";[36] = "rbxassetid://6936466691";[37] = "rbxassetid://6936483056";[38] = "rbxassetid://6936493138";[39] = "rbxassetid://6937103417";[40] = "rbxassetid://6937117942";[41] = "rbxassetid://6937131717";[42] = "rbxassetid://6937143355"
            }
            if last == #picId then last = 1  
            else last = last + 1 * game.Players.LocalPlayer.leaderstats.Rebirths.Value + 1
            end

            local pick = last 
            game.Workspace.Red["Square Painting"].Painting.Painting.Texture = picId[pick]
            game.ReplicatedStorage.ChangePictureEvent:FireClient(player,"This Image is called "..name[pick],picId[pick] )
            wait(5)
            script.Parent.Decal.Texture = "rbxgameasset://Images/untitled - 2020-09-03T235226.036"
            db = false
        end
    end
end)

Answer this question