Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with local player stats?

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)

5 comments

0

You're making smoke happeb before you give it the condition so @LetThereBeCode is right

0

He did not answer..

0

I am on tablet so I answered in chat

0

To repeat, put lines 6-11 under line 12

0

I fixed it

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.