Fix my speed boost shop script please!

Please fix my speed boost shop i have made it in a local script in a button!

Heres the script!
player = game.Players.LocalPlayer

local newWalkspeed = 50

script.Parent.MouseButton1Click:Connect(function()

if player.mapstats.Gems.Value <= 10 then

game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”).WalkSpeed = newWalkspeed

end

end)

wait(1)

2 Likes

If im right couldn’t you just try something like this.

script.Parent.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 85
end)

@ArchitectUnique try looking at “Leaderstats.Gems” more than mapstats?

the speed works well by itself but i am wanting it cost gems and when i and that if player.mapstats.Gems.Value <= then it just breaks

I think you shouldn’t use LocalScript since hackers can easily bypass your currency check. Make sure to do the check Server Sided!

Also can I see your leaderstats script?

okay here it is
local ds = game:GetService(“DataStoreService”):GetDataStore(“StatsSave”)

game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new(“Folder”, player)
stats.Name = “leaderstats”
local map = Instance.new(“Folder”, player)
map.Name = “mapstats”

local coins = Instance.new("IntValue", stats)
coins.Name = "Coins"

local power = Instance.new("IntValue", stats)
power.Name = "Junk"

local maps = Instance.new("IntValue", map)
maps.Name = "Maps"

local rank = Instance.new("StringValue", stats)
rank.Name = "Rank"

local item = Instance.new("StringValue", map)
item.Name = "itemowned"

local space = Instance.new("NumberValue", player)
space.Name = "capacity"

local level = Instance.new("IntValue", player)
level.Name = "Level"

local expMax = Instance.new("IntValue", level)
expMax.Name = "Max"

local exp = Instance.new("IntValue", level)
exp.Name = "XP"

local owned = Instance.new("IntValue", map)
owned.Name = "items"

local gem = Instance.new("NumberValue", map)
gem.Name = "Gems"

exp.Changed:Connect(function(val)
if exp.Value >= expMax.Value then
level.Value = level.Value + 1
exp.Value = 0
expMax.Value = expMax.Value * 1.2
end
end)

–[[power.Changed:Connect(function(val)
if power.Value >= space.Value then
power.Value = space.Value
end
end)
–]]

local store = ds:GetAsync(player.UserId)

if store ~= nil then
	coins.Value = store[1]
	power.Value = store[2]
	maps.Value = store[3]
	rank.Value = store[4]
	item.Value = store[5]
	space.Value = store[6]
	level.Value = store[7]
	expMax.Value = store[8]
	exp.Value = store[9]
    owned.Value = store[10]
    gem.Value = store[11]
	
else
	coins.Value = 0
	power.Value = 0
	maps.Value = 0
	rank.Value = "Rookie Janitor"
	item.Value = "Item0"
	space.Value = 25
	level.Value = 1
	expMax.Value = 100
	exp.Value = 0
	owned.Value = 0
    gem.Value = 0
	
	
end

end)

game.Players.PlayerRemoving:Connect(function(player)
local save = {}

table.insert(save, player.leaderstats.Coins.Value)
table.insert(save, player.leaderstats.Junk.Value)
table.insert(save, player.mapstats.Maps.Value)
table.insert(save, player.leaderstats.Rank.Value)
table.insert(save, player.mapstats.itemowned.Value)
table.insert(save, player.capacity.Value)
table.insert(save, player.Level.Value)
table.insert(save, player.Level.Max.Value)
table.insert(save, player.Level.XP.Value)
table.insert(save, player.mapstats.items.Value)
table.insert(save, player.mapstats.Gems.Value)

ds:SetAsync(player.UserId, save)

end)

So, here is how you can do it:

  1. Make a RemoteEvent in ReplicatedStorage
  2. FireServer the remote event when they click the button
  3. Listen to the Event in a SCRIPT
  4. Check if value is greater than or equal to 10
  5. Change walkspeed

Note: Put your code inside ``` to format it

1 Like

Please note that we are not here to fix/make scripts for you, we are here to help you debug your code, not write them for you.

1 Like

ye i was looking for something like the guy above you said

1 Like

So if you are trying to check if the player has more than or equal to gems the you used the wrong symbol.

— Use this symbol > for greater than