Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How Would I Make This Premium Membership Script Work?

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!

3 comments

0

use Connect instead of connect the ladder is deprecated

0

it didnt work

0

If the letter is deprecated, doesn't mean it doesn't work but you should always use:Connect

3 answers

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 :)

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.

1 comment

0

it didnt work

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.