Leaderstats value not changing

I am trying to make the leaderstats value equal the jumpheight of the player but when the button is pressed the leaderstats isn’t changing, i tried this in a local script and server script.

local script

local rs = game:GetService("ReplicatedStorage")
local remotevent = rs.StatsIncrease
local plr = game.Players.LocalPlayer
JUMPHEIGHT_INCREASE = 0.05
script.Parent.MouseEnter:Connect(function()
end)

script.Parent.MouseButton1Click:Connect(function()
	plr.Character.Humanoid.JumpHeight = plr.leaderstats.JumpPower.Value
	remotevent:FireServer(JUMPHEIGHT_INCREASE)
	
end)

server script:

local rs = game:GetService("ReplicatedStorage")
local remotevent = rs.StatsIncrease

remotevent.OnServerEvent:Connect(function(player, JUMPHEIGHT_INCREASE)
	player.Character.Humanoid.JumpHeight += JUMPHEIGHT_INCREASE
end)

You aren’t even referencing (well except for 1 time when you’re trying to get the value) the player’s leaderstats, obviously it’s not gonna change.

This doesn’t change a leaderstat value? It changes the jump height for the player who fired the event

  1. you can’t change leaderstats in a local script

  2. you are changing jump height to the leaderstats and not even changing the leaderstats

Here is the updated scripts and solution would be appreciated :heart:

Local script:

local rs = game:GetService("ReplicatedStorage")
local remotevent = rs.StatsIncrease
local plr = game.Players.LocalPlayer
JUMPHEIGHT_INCREASE = 0.05
script.Parent.MouseEnter:Connect(function()
end)

script.Parent.MouseButton1Click:Connect(function()
	remotevent:FireServer(JUMPHEIGHT_INCREASE)
end)

Server script:

local rs = game:GetService("ReplicatedStorage")
local remotevent = rs.StatsIncrease

remotevent.OnServerEvent:Connect(function(player, JUMPHEIGHT_INCREASE)
	player.Character.Humanoid.JumpHeight += JUMPHEIGHT_INCREASE
    player.leaderstats.JumpPower.Value = player.Character.Humanoid.JumpHeight
end)

ok yeah i wasnt being very smart here thanks for the help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.