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

[SOLVED] Leaderstat value is not changing any help ?

Asked by 3 years ago
Edited 3 years ago

I am making job for my game it is pizza delivery and i am making script to give money and score to player but when i try to change value nothing happend no errors or something it even print started so i want ask if somebody dont know what to do :c

workspace.Locations.GiveMoney.OnServerEvent:Connect(function()
    lplayer = script.Parent.Parent
    money = script.Parent.Parent.leaderstats.Money
    delivery = script.Parent.Parent.leaderstats.Deliveris
    okpizzajob = lplayer.Jobs.OKpizza

    if okpizzajob.Value == 1 then
        pizzatype = script.Parent.OKpizza.Job.Take.Pizza

        delivery.Value = delivery.Value + 1

        wait(0.1)
        if pizzatype.Value == 1 then
            money.Value = money.Value + 10
        end
        wait(0.1)
        if pizzatype.Value == 2 then
            money.Value = money.Value + 15
        end
        wait(0.1)
        if pizzatype.Value == 3 then
            money.Value = money.Value + 20
        end
    end
end)

0
cant see an issue othere than that you should use "local" instead of just listing your variables. matiss112233 258 — 3y

4 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

First, put your Remote Event in ReplicatedStorage (recommanded)

game.ReplicatedStorage.GiveMoney.OnServerEvent:Connect(function(player)
    local money = player.leaderstats.Money
    local delivery = player.leaderstats.Deliveris
    local okpizzajob = player.Jobs.OKpizza

    if okpizzajob.Value == 1 then
        local pizzatype = okpizzajob.Job.Take.Pizza

        delivery.Value = delivery.Value + 1

        wait(0.1)
        if pizzatype.Value == 1 then
            money.Value = money.Value + 10
        end
        wait(0.1)
        if pizzatype.Value == 2 then
            money.Value = money.Value + 15
        end
        wait(0.1)
        if pizzatype.Value == 3 then
            money.Value = money.Value + 20
        end
    end
end)

And put this script in ServerScriptService. Do double-check the variables and their location.

Please upvote and lemmeknow if it helps!

Edit: As discussed with you in Discord, the working script is:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        money = player.leaderstats.Money
        delivery = player.leaderstats.Delivery
        gui = player.PlayerGui
        okpizzajob = player.Jobs.OKpizza

        game.ReplicatedStorage.GiveMoney.OnServerEvent:Connect(function()
            print(okpizzajob.Value)
            if okpizzajob.Value == 1 then
                pizzatype = gui.OKpizza.Job.Take.Pizza
                print(pizzatype.Value)

                if pizzatype.Value == 1 then
                    money.Value = money.Value + 10
                    print("Money Given")
                elseif pizzatype.Value == 2 then
                    money.Value = money.Value + 15
                    print("Money Given")
                elseif pizzatype.Value == 3 then
                    money.Value = money.Value + 20
                    print("Money Given")
                end
            else
                print("no job")
            end
        end)
    end)
end)
0
still not working :c like script starts but it is not adding any money Souhall 3 — 3y
0
Double check the variable that I assigned to pizzatype variable BestCreativeBoy 1395 — 3y
0
Are you firing remove event from a local script? BestCreativeBoy 1395 — 3y
0
yes Souhall 3 — 3y
View all comments (11 more)
0
when i use this same thing but in local script it works but problem is i need it in script so other players can see leaderstats Souhall 3 — 3y
0
I dont think it will work on Local script, as there is OnServerEvent, and did you keep the script in ServerScriptService? BestCreativeBoy 1395 — 3y
0
And also check the local script that you are firing remote event of replicate storage only BestCreativeBoy 1395 — 3y
0
everything is in good place and script is working i added print so i can see if it works and yes but it is not changing idk why and i have basicly same script in other game but there is localscript and it is working :/ idk why it have problem with server scrpt Souhall 3 — 3y
0
it seems like int value cant be changed by server script :/ Souhall 3 — 3y
0
Try changing int value to number value BestCreativeBoy 1395 — 3y
0
still not changing (like ofc i can change it to local script and then other player will not see others score) Souhall 3 — 3y
0
Try removing wait() BestCreativeBoy 1395 — 3y
0
still nothing :C Souhall 3 — 3y
0
paste the script on dm on discord, Samyak@7649 BestCreativeBoy 1395 — 3y
0
ok my is MaximusMaaan#9963 Souhall 3 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

try elseif

workspace.Locations.GiveMoney.OnServerEvent:Connect(function()
    lplayer = script.Parent.Parent
    money = script.Parent.Parent.leaderstats.Money
    delivery = script.Parent.Parent.leaderstats.Deliveris
    okpizzajob = lplayer.Jobs.OKpizza

    if okpizzajob.Value == 1 then
        pizzatype = script.Parent.OKpizza.Job.Take.Pizza

        delivery.Value = delivery.Value + 1

        wait(0.1)
        if pizzatype.Value == 1 then
            money.Value = money.Value + 10
        end
        wait(0.1)
        elseif pizzatype.Value == 2 then
            money.Value = money.Value + 15
        end
        wait(0.1)
        elseif pizzatype.Value == 3 then
            money.Value = money.Value + 20
        end
    end
end)

0
nothing changed :( Souhall 3 — 3y
Log in to vote
0
Answered by 3 years ago

If you are using it on a local script, you need to either A: Switch to a server script B: Make a remote event to change it on the server C: (NOT RECOMMENDED) Turn off filtering enabled on workspace properties

0
nvm just realized you used ".OnServerEvent" so it's on a server (if it's on a local script then there is ur problem) SussiestBalss 40 — 3y
0
Turning off FE in the workspace won't actually turn it off. Where is that script/local script located? LightningLIon58 49 — 3y
0
sorry i was away and script is in PlayerGui Souhall 3 — 3y
Log in to vote
0
Answered by 3 years ago

BTW it is server script and all values are in player and line line 8 is checker if player is in job or no

0
May I know what actually Job is? Is it a stringValue? BestCreativeBoy 1395 — 3y
0
IntValue 1 means that u are in job and 0 is that u are not in job. and job is just job :D like it is food delivery game Souhall 3 — 3y
0
oh sowy job is folder where i will have other jobs i am stupid Souhall 3 — 3y

Answer this question