[SOLVED] Problem with Humanoid.WalkSpeed and Humanoid.JumpHeight

Hi Forum,

So what do I want to achieve is when the player triggers the proximity prompt, they won’t be able to walk and jump. Everything works fine until the Humanoid dies. Once the humanoid died and the player triggers the proximity prompt, the function won’t change the numbers for Humanoid.WalkSpeed or Humanoid.JumpHeight anymore.

Here’s the function:

local function onDialougeCalled()
	for i, v in pairs(workspace:GetDescendants()) do
		if v:IsA("ProximityPrompt") then
			v.Enabled = false
		end
	end
	Cam.CameraType = Enum.CameraType.Scriptable
	DialougeGui.Enabled = true
	MenuGui.Enabled = false
	BottomGui.Enabled = false
	CurrencyGui.Enabled = false
	Humanoid.WalkSpeed = 0
	Humanoid.JumpHeight = 0
end

The others things located in the function works fine after the Humanoid died.

Thanks for stopping by to help me :slight_smile:

2 Likes

Is this Local or Server script?

also, please show us the complete script.

2 Likes

Sure!

FireDialougePromptRemote.OnClientEvent:Connect(function(NPC)
    onDialougeCalled()
end
1 Like

Does the NPC respawn after dying?

1 Like

Here’s the Server script

local Prompt = script.Parent
local FireDialougePromptRemote = game.ReplicatedStorage:WaitForChild("FireDialougePrompt")

Prompt.Triggered:Connect(function(Player)
	if not Player.Vars:FindFirstChild("ChicksonDIL") then
		local Var = Instance.new("IntValue")
		Var.Value = 1
		Var.Name = "ChicksonDIL"
		Var.Parent = Player.Vars
		
		FireDialougePromptRemote:FireClient(Player, "Chickson")
	else
		Player.Vars:FindFirstChild("ChicksonDIL").Value += 1
		FireDialougePromptRemote:FireClient(Player, "Chickson")
	end
end)
1 Like

Where is the LocalScript that handles the client event located?
My current assumption is that you set the character variable in StarterPlayerScripts and it doesn’t update the variable when the player has a new character.

1 Like

I think I know the problem now since the original variable of Humanoid is outside the onDialougeCalled() therefore, when the “NPC” died the variable for humanoid gets destroyed too or set to nil since the parent of it died.

I suggest assigning the variable inside the onDialougeCalled().

2 Likes

The local script is located in a ScreenGui but I will try your solution

Is the property that resets the GUI on respawn enabled? If not, then you need to reassign your Humanoid variable as aforementioned.

1 Like

It’s working! Thank you for solving it!

1 Like

The problem was that I had the ScreenGui.ResetOnSpawn disabled. Thanks goes to @walshuk