Can't get my powerups to work

I’m trying to make a shop GUI where you can buy stackable powerups.
I’ve made a button for JumpPower and WalkSpeed, made some scripts with help from tutorials
(scripts visible below)
image

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.BuyEvents.WalkSpeedEvent:FireServer()
end)
script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.BuyEvents.jumpPowerEvent:FireServer()
end)

(Two events)
image

but then I couldn’t get it to give me the WalkSpeed Or JumpPower.

Then I made the server script… Well… Tried.
I tried a lot of stuff(which all horribly failed) and these are the ones I ended up with.
Yes, these.

game.ReplicatedStorage.BuyEvents.WalkSpeedEvent.OnServerEvent:Connect(function(player)

game.StarterPlayer.BuyPowerupWalkspeed.Disabled = false

end)

game.ReplicatedStorage.BuyEvents.jumpPowerEvent.OnServerEvent:Connect(function(player)

game.StarterPlayer.BuyPowerupJumpPower.Disabled = false

end)
local plr = game.Players:GetPlayerFromCharacter(player.Parent)
	if player.leaderstats.Level.Value >= 10 then
		player.leaderstats.Level.Value = player.leaderstats.Level.Value - 10
		plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed +20
	end
end)
local plr = game.Players:GetPlayerFromCharacter(player.Parent)
	if player.leaderstats.Level.Value >= 10 then
		player.leaderstats.Level.Value = player.leaderstats.Level.Value - 15
		plr.Character.Humanoid.JumpPower = plr.Character.Humanoid.JumpPower +30
	end
end)

I tried to make a script that lead to the other ones, depending on if you wanted Walkspeed or JumpPower.

2 big problems:

  • The script doesn’t work. :confused:

  • I still don’t precisely know how to change a player’s WalkSpeed/JumpPower.

I’ve searched on this devforum on how to fix it but I can’t…

I’m just a dum dum.

Problem video:

If any of you know how to fix this, please, help me!!!

-DarkeeDoo

1 Like

the problems are in the server script, you need to enable the script in the player…
…however this is exploitable so instead i would just do the code in the server like this:

game.ReplicatedStorage.BuyEvents.jumpPowerEvent.OnServerEvent:Connect(function(player)
	if player.leaderstats.Level.Value >= 10 then
		player.leaderstats.Level.Value -= 15
		player.Character.Humanoid.JumpPower += 30
	end
end)

game.ReplicatedStorage.BuyEvents.WalkSpeedEvent.OnServerEvent:Connect(function(player)
	if player.leaderstats.Level.Value >= 10 then
		player.leaderstats.Level.Value -= 10
		plr.Character.Humanoid.WalkSpeed += 20
	end
end)

then you can delete the scripts that you put in the starterplayer :slightly_smiling_face:

1 Like

Thank you! But it seems like there are still some problems in the script, I know how to fix them though.

One of them is a miscalculation of mine which lets people buy until they have -5 Level.

The other one seems to be an oopsie you made :grinning_face_with_smiling_eyes:
You put JumpPower twice instead of JumpPower and Walkspeed.

Thanks for the help!

-DarkeeDoo

1 Like

It’s already been solved, but I still appreciate you taking time out of your day to help!

-DarkeeDoo

1 Like

i fixed the oopsie and simplified the code a little bit, also could u mark it as a solution? thanks :smiley:

1 Like

Sorry for the late reply, but your post has been marked as a solution.

-DarkeeDoo

2 Likes