Hi everyone! I have scripted a speed upgrade shop but it isn’t working. Here is the script: (local)
local player = game.Players.LocalPlayer
local nowalkspeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed
script.Parent.Text = "30 Coins"
local AmountLeft = script.Parent.Parent.AmountOfUpgrades.AmountLeft
local AmountUpgraded = script.Parent.Parent.AmountOfUpgrades.AmountUpgraded
script.Parent.Parent.AmountOfUpgrades.Text = AmountUpgraded.Value.." / "..AmountLeft.Value
script.Parent.MouseButton1Click:Connect(function()
print("pressed upgrade")
script.Parent.Parent.AmountOfUpgrades.Text = AmountUpgraded.Value.." / "..AmountLeft.Value
if AmountUpgraded.Value == 2 then
if player:WaitForChild("leaderstats").Coins.Value >= 30 then
player:WaitForChild("leaderstats").Coins.Value -= 30
AmountUpgraded.Value = AmountUpgraded.Value + 1
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 5
script.Parent.Text = "50 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "50 Coins"
end
elseif AmountUpgraded.Value == 3 then
if player:WaitForChild("leaderstats").Coins.Value >= 50 then
player:WaitForChild("leaderstats").Coins.Value -= 50
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 10
script.Parent.Text = "100 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "100 Coins"
end
elseif AmountUpgraded.Value == 4 then
if player:WaitForChild("leaderstats").Coins.Value >= 100 then
player:WaitForChild("leaderstats").Coins.Value -= 100
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 15
script.Parent.Text = "150 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "150 Coins"
end
elseif AmountUpgraded.Value == 5 then
if player:WaitForChild("leaderstats").Coins.Value >= 150 then
player:WaitForChild("leaderstats").Coins.Value -= 150
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 20
script.Parent.Text = "200 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "200 Coins"
end
elseif AmountUpgraded.Value == 6 then
if player:WaitForChild("leaderstats").Coins.Value >= 200 then
player:WaitForChild("leaderstats").Coins.Value -= 200
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 25
script.Parent.Text = "250 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "250 Coins"
end
elseif AmountUpgraded.Value == 7 then
if player:WaitForChild("leaderstats").Coins.Value >= 250 then
player:WaitForChild("leaderstats").Coins.Value -= 250
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 30
script.Parent.Text = "300 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "300 Coins"
end
elseif AmountUpgraded.Value == 8 then
if player:WaitForChild("leaderstats").Coins.Value >= 300 then
player:WaitForChild("leaderstats").Coins.Value -= 300
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 35
script.Parent.Text = "350 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "350 Coins"
end
elseif AmountUpgraded.Value == 9 then
if player:WaitForChild("leaderstats").Coins.Value >= 350 then
player:WaitForChild("leaderstats").Coins.Value -= 350
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 40
script.Parent.Text = "400 Coins"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "400 Coins"
end
elseif AmountUpgraded.Value >= 10 then
if player:WaitForChild("leaderstats").Coins.Value >= 400 then
player:WaitForChild("leaderstats").Coins.Value -= 400
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = nowalkspeed + 10
script.Parent.Text = "MAXED"
print(game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed)
else
print(player.Name.. " doesn't have enough coins to upgrade")
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0.0156863)
script.Parent.Text = "Not Enough Coins!!"
task.wait(1)
script.Parent.BackgroundColor3 = Color3.new(1, 0.85098, 0)
script.Parent.Text = "MAXED"
end
end
end)
It would probably be useful for anyone trying to help to know that “pressed upgrade” does print in the output.