Hey Developers, I’m stuck again on another script problem. Let me explain, Basically Ive been trying to make a simulator game on Roblox. And I want to make it so where when a player Jumps, it’s triggers a the local script within the tool. When the game is launched, each player would be given a tool. When the player equips the tool and jumps it will add 1 to the leader stats. I know this isn’t the best explanation, but that’s besides the point. I need some help.
local player = game.LocalPlayer
script.Parent.Equipped:Connect(function()
player.Charecter.Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower + player.JumpUPG.Value
end)
script.Parent.Unequipped:Connect(function()
player.Charecter.Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower - player.JumpUPG.Value
end)
while wait(1) do
if player.Charecter.Humanoid.Jump == true then
player.leaderstats.JumpPower.Value = player.leaderstats.JumpPower.Value +1
end
end
as @AC_Starmarine said, you can’t add leaderstats on the client, but after you change this to a script, instead of using wait and checking if they are jumping, use
Make a remote event in replicated storage. This is where items that can be accessed by the client and server go.
Here is a tutorial I found to help you.
I’m pretty sure he’s aware, it’s just that the issue here is with client-server replication
If you change the Value from the client, it will only be visible & accessible to your side
If you change it from the Server however, it can be accessed from anywhere since it’s being added globally
Also there’s a much better approach of detecting when the Character will jump instead of having to use a while wait(1) do loop
local player = game.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
script.Parent.Equipped:Connect(function()
Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower + player.JumpUPG.Value
end)
script.Parent.Unequipped:Connect(function()
Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower - player.JumpUPG.Value
end)
Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if Humanoid.Jump == true then
--Do stuff here
end
end)