of     1   

Raildex
#182502793Wednesday, January 27, 2016 3:44 PM GMT

What is the correct way to access the users stat values. I've attempted it here but have failed. local car1 = game:GetService("ReplicatedStorage")["Car"] --local backup = car1:clone() local car2 = game:GetService("ReplicatedStorage")["Van"] --local backup2 = car2:clone() local car3 = game:GetService("ReplicatedStorage")["Off-Roader"] --local backup3 = car3:clone() carN = script.Parent.Parent.carValue local carV local backup cooldown = false function Regen(player) if(carN.Value == 1) then backup = car1:clone() print("set to Sedan") end if(carN.Value == 2) then backup = car2:clone() print("set to Van") end if(carN.Value == 3) then backup = car3:clone() print("set to Jeep") end if(cooldown == false) then ------------------------------THIS HERE-------------------------- local user = game.Players:GetPlayerFromCharacter(player) local stats = user:findFirstChild("leaderstats") if stats ~= nil then local cash = stats:findFirstChild("Cash") --Money Name! print("found cash") if cash.Value > (script.Parent.Parent.CostV.Value-1) then print("has Money") cash.Value = cash.Value - script.Parent.Parent.CostV.Value ------------------------------------- carV = backup:clone() carV.Parent = game.Workspace carV:makeJoints() carV:SetPrimaryPartCFrame (script.objectValue.Value.CFrame+Vector3.new(0,5,0)) carV:SetPrimaryPartCFrame (car1.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(180), 0)) print(carV.PrimaryPart) cooldown = true script.Parent.Text = "On Cooldown" wait(12) cooldown = false script.Parent.Text = "Build" end end end end script.Parent.MouseButton1Down:connect(Regen)What is the correct way to access the users stat values. I've attempted it here but have failed. local car1 = game:GetService("ReplicatedStorage")["Car"] --local backup = car1:clone() local car2 = game:GetService("ReplicatedStorage")["Van"] --local backup2 = car2:clone() local car3 = game:GetService("ReplicatedStorage")["Off-Roader"] --local backup3 = car3:clone() carN = script.Parent.Parent.carValue local carV local backup cooldown = false function Regen(player) if(carN.Value == 1) then backup = car1:clone() print("set to Sedan") end if(carN.Value == 2) then backup = car2:clone() print("set to Van") end if(carN.Value == 3) then backup = car3:clone() print("set to Jeep") end if(cooldown == false) then ------------------------------THIS HERE-------------------------- local user = game.Players:GetPlayerFromCharacter(player) local stats = user:findFirstChild("leaderstats") if stats ~= nil then local cash = stats:findFirstChild("Cash") --Money Name! print("found cash") if cash.Value > (script.Parent.Parent.CostV.Value-1) then print("has Money") cash.Value = cash.Value - script.Parent.Parent.CostV.Value ------------------------------------- carV = backup:clone() carV.Parent = game.Workspace carV:makeJoints() carV:SetPrimaryPartCFrame (script.objectValue.Value.CFrame+Vector3.new(0,5,0)) carV:SetPrimaryPartCFrame (car1.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(180), 0)) print(carV.PrimaryPart) cooldown = true script.Parent.Text = "On Cooldown" wait(12) cooldown = false script.Parent.Text = "Build" end end end end script.Parent.MouseButton1Down:connect(Regen)
brados123
#182505794Wednesday, January 27, 2016 5:12 PM GMT

whats the reason behind you needing to use leaderstats? cant you just use regular intvalues, make your gui, insert a localscript etc.
brados123
#182505814Wednesday, January 27, 2016 5:12 PM GMT

ill script it for some of those sweet limiteds xD
Raildex
#182506372Wednesday, January 27, 2016 5:29 PM GMT

I need to be able to take away cash when purchasing a car from the gui
TheTrueRias
#182506474Wednesday, January 27, 2016 5:32 PM GMT

this is really ugly code ok but uh you probably want to use a localscript and if you are just use game.Players.LocalPlayer.leaderstats.val
Vezious
#182506496Wednesday, January 27, 2016 5:33 PM GMT

Using a player's leaderstats as the main source is a bad habit. Your games is vulnerable to exploiters that can change stats.
TheTrueRias
#182506536Wednesday, January 27, 2016 5:34 PM GMT

@vez probably put them in serverstorage and communicate the localscript and a serverscript that changes stats via invokeserver
Vezious
#182506663Wednesday, January 27, 2016 5:37 PM GMT

Or even better, keep them only in a script.
Raildex
#182506708Wednesday, January 27, 2016 5:38 PM GMT

could I do it like this? local cash = game.Players.LocalPlayer.leaderstats.Cash if cash.Value > (script.Parent.Parent.CostV.Value-1) then print("has Money") cash.Value = cash.Value - script.Parent.Parent.CostV.Value
Vezious
#182506840Wednesday, January 27, 2016 5:41 PM GMT

Ugh, whatever, The Ineffective way: local Stats = You Set it local Charge = 500 if Stats then if Stats >= Charge then print("0MG D1$ $KRU3 H4$ M0N3Y") else print("H03041yf3")

    of     1