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.
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)
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.
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().