I am making a function for days now that finds a Instance and then returns it. I've simplified to change a player's score to a number specified by an argument.
Here is the function in script and ModuleScript form (Requires leaderstats and a IntValue called 'Points' parented under it.):
SCRIPT VERSION:
function GivePlayerSomePoints(plr,num)
local player;
if (tostring(plr)) then
player = game.Players[plr];
elseif (plr.ClassName) then
player = plr;
else
warn("Player doesn't exist.");
return nil; -- Stop function.
end;
if (player.leaderstats.Points) then
if (num) then
if (tonumber(num)) then
player.leaderstats.Points.Value = player.leaderstats.Points.Value + num;
end;
end;
end;
end;
wait(30); -- Wait until player object exists.
GivePlayerSomePoints(YOURNAME,50);
MODULESCRIPT VERSION
-- In a ModuleScript
local test = {}
function test:GivePlayerSomePoints(plr,num)
local player;
if (tostring(plr)) then
player = game.Players[plr];
elseif (plr.ClassName) then
player = plr;
else
warn("Player doesn't exist.")
return nil; --Stop function.
end;
if (player.leaderstats.Points) then
if (num) then
if (tonumber(num)) then
player.leaderstats.Points.Value = player.leaderstats.Points.Value + num;
end;
end;
end;
end;
return test;
-- In a script
wait(30)
local ModuleScript = require(game.Workspace.ModuleScript)
ModuleScript:GivePlayerSomePoints(YOURNAME),50)
I can post my original function if wanted.

1 comment
Thank you, good sir.