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

I did this Speed Upgrade Thing But I want It to take Money away How do I do it?

i want it to take money away when I get a speed Boost But It wont Work and I don't Get any errors Either

button = script.Parent
player = game.Players.LocalPlayer
char = player.Character
humanoid = char.Humanoid
price = 50
speed = 17
max = false

button.MouseButton1Click:connect(function()
if humanoid.WalkSpeed == 140 then	


if player.leaderstats.Money <= price then
		print("Not Enough")

elseif max == false then
humanoid.WalkSpeed = speed
speed = speed + 1
price = price + 25
player.leaderstats.Money = player.leaderstats.Money - price
wait(2)
end
end
end)

5 comments

0

do you have filtering on?

0

no

0

Y does that Make Any difference?

0

Because if it was on that would be a bigger problem. Il answer below

0

Ok Thx

1 answer

✓ Accepted answer

When you are trying to remove the money and check it, you are forgetting to add .Value. This is required to get the value of a Value Object.

button = script.Parent
player = game.Players.LocalPlayer
char = player.Character
humanoid = char.Humanoid
price = 50
speed = 17
max = false

button.MouseButton1Click:connect(function()
if humanoid.WalkSpeed == 140 then   


if player.leaderstats.Money.Value <= price then
        print("Not Enough")

elseif max == false then
humanoid.WalkSpeed = speed
speed = speed + 1
price = price + 25
player.leaderstats.Money.Value = player.leaderstats.Money.Value - price
wait(2)
end
end
end)

5 comments

0

Ok let me try that and Thx

0

Sorry but It wont Work

0

try adding player.CharacterAdded:wait() on line 4

0

ok

0

that was Not the Answer But U leaded Me To The solution, it was that i forgot an else for Line 10 But thx Ill take your help

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