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

Help with local player stats?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

When I have less than 100 points, I still get smoke to my torso. I am supose to have more than 100 points..

--//Variables
local player = game.Players.LocalPlayer
points = player.Points
--//Function
script.Parent.MouseButton1Click:connect(function()
    if not player.Character.Torso:FindFirstChild('Smoke') then
        local sm = Instance.new("Smoke")
        sm.Size = .1
        sm.Opacity = .1
        sm.Parent = player.Character.Torso
    end
            if points.Value > 100 then --100 = price
                script.Parent.Text = "Smoke"
                points.Value = points.Value - 100
            else
                script.Parent.Text = "Not enough points!"
                wait(2)
                script.Parent.Text = "Smoke: 100 Points"

        end
end)
0
You're making smoke happeb before you give it the condition so @LetThereBeCode is right TrollD3 105 — 8y
0
He did not answer.. FiredDusk 1466 — 8y
0
I am on tablet so I answered in chat LetThereBeCode 360 — 8y
0
To repeat, put lines 6-11 under line 12 LetThereBeCode 360 — 8y
0
I fixed it FiredDusk 1466 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

You also need to add a value inside the button, which stores how much points you need to buy it. Add an if statement inside the button that replaces the check. The script cannot do anything unless the check returns true. Since it might be hard to understand, I will fix it for you:

--//Variables
local player = game.Players.LocalPlayer
local points = player.Points
local price = script.Parent.PriceValue
--//Function
script.Parent.MouseButton1Click:connect(function()
        if not player.Character.Torso:FindFirstChild('Smoke') then
            if points.Value >= price.Value then
                points.Value = points.Value - price.Value
                local sm = Instance.new("Smoke")
                sm.Size = .1
                sm.Opacity = .1
                sm.Parent = player.Character.Torso
            elseif points.Value > price.Value then
                script.Parent.Text = "Not enough points!"
                script.Parent.Selectable = false
                wait(2)
                script.Parent.Selectable = true
                script.Parent.Text = "Smoke: 100 Points"
            end
        end
end)
Ad

Answer this question