Jump to content

Scripts variable not updating?


Recommended Posts

Hello!, I am currently working on my simulator game and i made a script so when the player clicks with the tool it will fire the event, this works but whoever if i change the playerstats for "multiplier" or "addition" the variables wont update, i have proven this by using print (multiplier) statements and even if i change it to whatever it will still print "1" which is what its set to in my playerstats folder. Any help appreciated, scripts below: 

 

game.ReplicatedStorage.addevent.OnServerEvent:Connect(function(plr)
local addition = plr.playerstats.addition
local multiplier = plr.playerstats.multiplier
local gamepass = 8784518
local service = game:GetService("MarketplaceService")
    
    
    if plr.leaderstats.Spins.Value < plr.playerstats.MaxValue.Value
    and service:UserOwnsGamePassAsync(plr.UserId, gamepass) then
        plr.leaderstats.Spins.Value = plr.leaderstats.Spins.Value + addition.Value*multiplier.Value*2  print("DoublePass Pay!")
        if plr.leaderstats.Spins.Value > plr.playerstats.MaxValue.Value then
            plr.leaderstats.Spins.Value = plr.playerstats.MaxValue.Value
            end
    elseif service:UserOwnsGamePassAsync(plr.UserId, gamepass) == false then
            if plr.leaderstats.Spins.Value < plr.playerstats.MaxValue.Value then
            plr.leaderstats.Spins.Value = plr.leaderstats.Spins.Value + addition.Value*multiplier.Value print("Normal Pay") print(multiplier.Value)
            if plr.leaderstats.Spins.Value > plr.playerstats.MaxValue.Value then
            plr.leaderstats.Spins.Value = plr.playerstats.MaxValue.Value
        end
        end
        end
        end)

Share this post


Link to post
Share on other sites
  • 3 weeks later...

Make sure capitalization is correct, also, you don't need the second elseif, just make it else and run the next block of code.

 

 elseif service:UserOwnsGamePassAsync(plr.UserId, gamepass) == false then

becomes

 else

Share this post


Link to post
Share on other sites
  • 2 months later...

The Marketplace Server does can't return a false bool with the UserOwnsGamePassAsync. You're better going with what @SPOOK_EXE said

Edited by orcazate

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.