This isn't working because you haven't actually allocated the FloorMaterial property of Humanoid properly. The Conditional you've written actually check for the Humanoid, also attempts to compare it to an Enum type, which should definitely throw exceptions. Yet, I believe nothing is actually erroring because you're receiving something similar to an Infinite yield. This occurs when the attempted variable declaration is ran before the respective object has the time to load. We can actually condition the declaration to wait for said object before trying to allocate it!
All the code you're looking for will be below:
local Player = game:GetService("Players").LocalPlayer
local Cursor = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
Cursor.Button1Down:Connect(function())
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if (Humanoid) then
if (Humanoid.FloorMaterial == Enum.FloorMaterial.Grass) then
end
end
end)
2 comments
Please ensure this is a LocalScript within StarterPlayerScripts
Oh, it's in starter char scripts