For some reason, my script is not triggering when the player has a morph equipped, could anyone help please?
local character = plr.Character
local Humanoid = character.Humanoid
local timeScale = 3
local gravity = 196.2
local walkSpeed = 16
local slowedWalkSpeed = walkSpeed/timeScale
local slowedGravity = gravity/(timeScale * 7)
function OnTouch()
if character:FindFirstChild("Humanoid") then
if Humanoid ~= nil then
print("IT PRINTS")
Humanoid.WalkSpeed = slowedWalkSpeed
end
elseif Humanoid.FloorMaterial == Enum.Material.Air then
end
end
game.Workspace.SlowMoStartPart.Touched:Connect(OnTouch)
function NewOnTouch()
if character:FindFirstChild("Humanoid") then
if Humanoid ~= nil then
print("IT PRINTS AGAIN")
Humanoid.WalkSpeed = walkSpeed
end
elseif Humanoid.FloorMaterial == Enum.Material.Air then
end
end
game.Workspace.CorridorExpulsionTrigger.Touched:Connect(NewOnTouch)```
Maybe because the morph has changed the players humanoid, so you need to redefine the character.
Part.Touched:Connect(function(Hit)
local Character
if Hit.Parent:FindFirstChild("Humanoid") then
Character = Hit.Parent
elseif Hit.Parent.Parent:FindFirstChild("Humanoid") then -- hit was parent in an accessory
Character = Hit.Parent.Parent
end
-- do your stuff
end)
function OnTouch(part)
if part.Parent:FindFirstChild("Humanoid") then
if Humanoid ~= nil then
print("IT PRINTS")
Humanoid.WalkSpeed = slowedWalkSpeed
end
elseif Humanoid.FloorMaterial == Enum.Material.Air then
end
end
game.Workspace.SlowMoStartPart.Touched:Connect(OnTouch(part))
When you’re in the air look at the FloorMaterial property. It’s blank. Even though it’s not technically nil, I’m not sure you can reference it in the manner you want using “Air”. Which is weird since running “Print (Humanoid.FloorMaterial.Name)” will yield you “Air” in the output, but I’m guessing that’s the problem.
game.Workspace.SlowMoStartPart.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
if Humanoid ~= nil then
print("IT PRINTS")
Humanoid.WalkSpeed = slowedWalkSpeed
end
elseif Humanoid.FloorMaterial == Enum.Material.Air then
end
end)