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

How would I make a give points command?

Asked by 4 years ago

Anyone know how I would do this? This is my script so far:

local Players = game:GetService("Players")
local Prefix = ":"
local GroupId = Int

Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(GroupId) >= Int then
        Player.Chatted:Connect(function(msg)
            if msg:Sub(1,11) == Prefix.."AddPoints " then
                local Target = Players:FindFirstChild(msg:Sub(12))
            end
        end)
    end
end)

1 answer

Log in to vote
1
Answered by
KDarren12 705 Donator Moderation Voter
4 years ago

I know this is not in your script, but you could also use a function that allows you to shorten the chatted name of a player in the game. For example: (without function) ;kill KDarren12, (with function) ;kill KD.

function GetPlayer(targetedPlayerName)
      for _,player in pairs(game:GetService("Players"):GetPlayers()) do
            if targetedPlayerName:lower() == player.Name:sub(1,targetedPlayerName:len()):lower() then
                return player 
            end
        end
        return nil 
end


local Prefix = ":"
local GroupId = Int

Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(GroupId) >= Int then
        Player.Chatted:Connect(function(msg)
            if msg:Sub(1,11) == Prefix.."AddPoints " then
                local Target = GetPlayer(msg:sub(12))
           -- I do not know if they are leaderstats, but here:
        print("Added points to player "..Target)
            end
        end)
    end
end)
0
Thx! I am going to learn from this script Microsoft_Net 21 — 4y
0
No problem. I hope you can do something great, good luck! KDarren12 705 — 4y
0
but one question, I know that it can get the player but what if I wanted to do :AddPoints [Plr] and then the number Microsoft_Net 21 — 4y
0
Do you want to do [number], [plr]? KDarren12 705 — 4y
View all comments (7 more)
0
better question, do you have leaderstats? And if so, what are they? KDarren12 705 — 4y
0
It is just Player.leaderstats.Points.Value Microsoft_Net 21 — 4y
0
I'm nto sure how to do that. I've heard about string.split but have not learned how to use it. I'm so sorry if I couldn't fully answer your question. KDarren12 705 — 4y
0
it's good i fixed it now :) Microsoft_Net 21 — 4y
0
alr good day KDarren12 705 — 4y
0
not relevant but i recognize you from void script builder SilverCreeper58 23 — 4y
0
me or microsoft? KDarren12 705 — 4y
Ad

Answer this question