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

How Would I Make This Premium Membership Script Work?

Asked by
iWasThisi -15
4 years ago

So I Wanted To Say If The Person Had Premium They Get 2x Points, But This Script Didn't Work, Help!

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
    if player.MembershipType == Enum.MembershipType.Premium then
    player.CharacterAdded:connect(function(char)
        plr.leaderstats.Points.Value = plr.leaderstats.Points.Value * 2
        end)

Please Respond And Thanks For Your Help!

0
use Connect instead of connect the ladder is deprecated quinzt 201 — 4y
0
it didnt work iWasThisi -15 — 4y
0
If the letter is deprecated, doesn't mean it doesn't work but you should always use:Connect SilentsReplacement 468 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

I believe the issue is you're trying to multiply the existing leaderstats value by 2, therefore doubling the amount of points they have at that point in time only once. Considering you have no datastores, the player will spawn with 0 points. The script will detect the player is premium, and double 0, which is still 0.

The fix to your problem is to double the points whenever the player earns them, not by doubling the points they have at that moment. Check if the player is premium, double the amount of points they will earn, and THEN give it to them.

Let me know if this helps :)

Ad
Log in to vote
0
Answered by
crueluu 169
4 years ago
Edited 4 years ago

maybe Re-Place The "player.CharacterAdded:Connect" in the line after "game.Players.PlayerAdded" It Might Be The Problem

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)

player.CharacterAdded:connect(function(char)
    if player.MembershipType == Enum.MembershipType.Premium then

        player.leaderstats.Points.Value = player.leaderstats.Points.Value * 2
end
        end)
end)

I Think This Is A Better Way To Execute It, Plus You Refrenced The Player As "player" but in line(6) you wrote "plr" which is nil because you didnt refrence the player as "plr" but instead "player",sorry if this is confusing hope I Helped.

0
it didnt work iWasThisi -15 — 4y
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
    if player.MembershipType == Enum.MembershipType.Premium then
    player.CharacterAdded:connect(function(char)
        player.leaderstats.Points.Value = player.leaderstats.Points.Value * 2

end)
end)

The problem is that you tried to increase the leader stats of plr not player since you passed the argument for the player. Also, you have missed an end. I've fixed your script and you should be good to go!

Answer this question