I believe this has to do with how roblox checks what is touching and what isn’t by checking if anything is touching one of the faces and not if there is something inside. You can simply fix this by using the touched event and the workspace:getpartsinpart() function.
Edit: use an if statement to check if once the part isn’t being touched anymore then check how many part are in it and if it is more than 0 then do not call this function.
Also by the way, I don’t know if you can understand how this modul works but i’m gonna mention it, ForeverHD made an amazing modul that works like Touch and TouchEnded but is much more better and accurate.
Even though you’re still touching the block from a player’s perspective, there might be moments during jumping when the character’s hitbox is not in contact with the block. This could be due to a slight gap that might occur during the jumping animation, even if it’s just for a fraction of a second.
local Humanoid = script.Parent:FindFirstChild("Humanoid")
local RootPart = script.Parent:FindFirstChild("HumanoidRootPart")
local Block = game.Workspace:FindFirstChild("Block")
local RayLength = 3 -- The length of the raycast. Adjust as needed.
local function CheckIfOnBlock()
local RayOrigin = RootPart.Position
local RayDirection = Vector3.new(0, -RayLength, 0)
local RaycastParams = RaycastParams.new()
RaycastParams.FilterType = Enum.RaycastFilterType.Blacklist
RaycastParams.FilterDescendantsInstances = {script.Parent} -- Prevents ray from detecting the player itself
local Ray = workspace:Raycast(RayOrigin, RayDirection, RaycastParams)
if Ray and Ray.Instance == Block then
return true
else
return false
end
end
Humanoid.Jumping:Connect(function()
wait(0.1) -- Waits a moment to see if player has really stopped touching the block
if not CheckIfOnBlock() then
script.Parent.Transparency = 0
wait(.1)
script.Parent.Transparency = .5
end
end)