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

How do I transfer an intvalue of something to leaderstats values?

Asked by 8 years ago
01local money = script.Parent:WaitForChild("money").Value
02function payout(plr)
03    local plrname = (plr.Name)--this is for later when the tycoon gets the name from the owner door
04    local srvrmoney = game.Players[plrname]:FindFirstChild(leaderstats.money.Value)--might have to be changed to waitforchild idk yet
05    if plr.Name == "macabe55101" then
06        srvrmoney = money
07    end
08end
09 
10game.workspace.moneygiver.Touched:connect(payout)

this is the best I have so far I think I messed up with the syntax needed on line 1... Im trying to transfer the value of a intvalue to another in a player in leaderstats once the game is run.

0
also line 5 will be changed to be whichever player owns the tycoon, but that's besides the point macabe55101 38 — 8y
0
define 'money' inside the function. Otherwise it will be the same number everytime. Goulstem 8144 — 8y
0
money is a intvalue place holder macabe55101 38 — 8y
0
bump plez halp sermone macabe55101 38 — 8y
View all comments (2 more)
0
Maybe it has something to do with srvrmoney. srvrmoney is the value of the money and when you are changing it later on in the function it is changing the variable value and not the IntValue Value RGRage 45 — 8y
0
Correct me if i'm wrong... RGRage 45 — 8y

1 answer

Log in to vote
0
Answered by
RGRage 45
8 years ago

Value has not been used correctly:

01local money = script.Parent:WaitForChild('money') -- Using the value of the object will get the value for one time only, so use the object and get the value later
02 
03function payout(hit) -- Change plr to hit because this function is being called by a touched event, hit is the part that is being hit
04 
05    if hit.Parent:FindFirstChild('Humanoid') then -- If there is a humanoid then hit's parent is more likely to be a player
06 
07        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
08 
09        if plr ~= nil then -- checks to see if it is actually a player
10 
11            local plrname = (plr.Name) -- plr's Name
12 
13            if plrname == 'macabe55101' then
14                local srvrmoney = plrl:FindFirstChild('leaderstats').money --This is the object for srvrmoney
15 
View all 23 lines...

If I am wrong please correct me, but if I helped please accept.

0
"~= nil" on line 9 of your code isn't necessary, as the "if" statement will return true if the values presented to it are equal, or true. TheeDeathCaster 2368 — 8y
0
@TheAlphaStigma, Thanks I'll keep that in mind. RGRage 45 — 8y
Ad

Answer this question