JumpPower script doesnt work!

can someone please help me with this scirpt! its supposed to change players jumppower to 150 after a remote event is fired but it doesnt change the jumpower can someone please fix it! i really dont see wehre tis wrong

local Players = game:GetService("Players")

-- Reference to the RemoteEvent
local jumpPowerEvent = script.Parent.RemoteEvent

-- Function to change jump power
local function onJumpPowerEvent()
	local player = Players.LocalPlayer
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")

	-- Store the original JumpPower
	local originalJumpPower = humanoid.JumpPower

	-- Modify Humanoid's JumpPower property directly
	humanoid.JumpPower = 150

	-- Wait for 1 second and then reset JumpPower
	wait(1)
	humanoid.JumpPower = originalJumpPower
end

-- Connect the function to the RemoteEvent
jumpPowerEvent.OnClientEvent:Connect(onJumpPowerEvent)

I think you have to use JumpHeight

2 Likes

i tried it rn it still doesnt work maybe theres another way

The problem is probably that your firing the event wrong, or you have this local script in a bad position, it should be in startercharacterscripts.

show the server script

i already checked the local script it works fine its the problem with the server script i think

this is the serverscript you mean the lcoal script tha fires the remote event?

This is not a server script, why are you accessing the local player in a server script? That doesn’t exist on the server.

-- local script events function as:

local Event = Path.To.Event
Event.OnClientEvent(any)
-- server script events function as:

local Event = Path.To.Event
local TargetPlayer = player
Event:FireClient(TargetPlayer, any)
or
Event:FireAllClients(any)

put the variable outside the function

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local originalJumpPower = humanoid.JumpPower

-- Reference to the RemoteEvent
local jumpPowerEvent = script.Parent.RemoteEvent

-- Function to change jump power
local function onJumpPowerEvent()


	-- Modify Humanoid's JumpPower property directly
	humanoid.JumpPower = 150

	-- Wait for 1 second and then reset JumpPower
	wait(1)
	humanoid.JumpPower = originalJumpPower
end

-- Connect the function to the RemoteEvent
jumpPowerEvent.OnClientEvent:Connect(onJumpPowerEvent)

everytime you call the function you are setting the variable again and again
@super_marvel1232

Hiyah, I took a reading of what happened here.
My questions are.
1: Is this script a server script or localscript?
2: Is the remote being fired from a server script?

Buddy why are you changing it on the client, you can (read: NEED to)change it on the server itself. Also you need to tell the script you want to use the jump power before changing it
Final code in A SERVER SCRIPT

—[[I’m going to change the power
When the player joins, you change that
to whatever event you use to change the power]]—
game.Players.PlayerAdded:Connect(function(plr)
   local hum = (plr.Character or plr.CharacterAdded:Wait()).Humanoid
   local originalpower = hum.JumpPower
   hum.UseJumpPower = true
   hum.JumpPower = 150
   wait(1)
   hum.JumpPower = originalpower
end)

The problem in your script is probably because you are trying to change the JumpPower property of the humanoid on the client side (i.e. on the local player). Changes to the physical properties of player elements (like JumpPower) on the client side are often not replicated and can therefore be ignored by the server.

Hi this is a serverscirpt and the remote is beign fired from a lcoalscript

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