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