So i try to detect wich material the player is walking on, then print it but, it print “Enum.Material.Plastic” and i want it to only print “Plastic”.
Here is my code:
--!nonstrict
-- // FileName: walkmaterial.lua
-- // Written by: Metafolder
-- // Description: change walk speed with material.
local WalkMaterialModule = {}
function WalkMaterialModule.Detect()
local Source = script.Parent.Parent.Parent
local GlobalVar = require(Source.Variable.variable)
local SpeedChanger = require(Source.Event.PlayerFolder.PlayerModule.speedchanger)
local Character = GlobalVar.Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local MoveDirection = Humanoid.MoveDirection
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if Humanoid.MoveDirection.Magnitude > 0 and LastMaterial ~= Humanoid.FloorMaterial then
LastMaterial = Humanoid.FloorMaterial
SpeedChanger.Set(LastMaterial)
print(LastMaterial) --Then it print "Enum.Material.Plastic"
end
end)
end
return WalkMaterialModule