I have a custom effect for developer, But i need the part that holds the emitters to always be on the ground, No matter how high the player is. It always needs to touch the ground. But i have some issues with it. So i need some help
Code:
local rootpart = char.HumanoidRootPart
local clone = game.ServerStorage.DevPlayerEffect:Clone()
clone.Parent=rootpart
clone.CanCollide=false
clone.CanQuery=false
clone.CanTouch=false
clone.Anchored=true
clone.Clusters.CanCollide=false
clone.Clusters.CanQuery=false
clone.Clusters.CanTouch=false
clone.Clusters.Anchored=true
clone.Transparency=1
clone.UI.BillboardGui.TextLabel.Text=player.DisplayName.." ("..player.Name..")"
clone.UI.Parent=rootpart.Parent:FindFirstChild("Head")
rootpart.Parent:FindFirstChild("Head"):WaitForChild("VIPGui"):Destroy()
while task.wait() do
clone.CFrame=CFrame.new(rootpart.CFrame.Position)*CFrame.new(0,-2,0)
clone.Clusters.CFrame=clone.CFrame
end
U there? @azqjanna, I need your help.
It does not want to work.
Current code:
local rootpart = char.HumanoidRootPart
local origin = rootpart.CFrame.Position
local Direction = Vector3.new(0,-20,0)
local rayDirection = Direction - origin
local Result = workspace:Raycast(origin, rayDirection)
local clone = game.ServerStorage.OmniverseEffectPlayer:Clone()
clone.Parent=rootpart
clone.CanCollide=false
clone.CanQuery=false
clone.CanTouch=false
clone.Anchored=true
clone.Clusters.CanCollide=false
clone.Clusters.CanQuery=false
clone.Clusters.CanTouch=false
clone.Clusters.Anchored=true
clone.Transparency=1
clone.UI.BillboardGui.TextLabel.Text=player.DisplayName.." ("..player.Name..")"
clone.UI.Parent=rootpart.Parent:FindFirstChild("Head")
rootpart.Parent:FindFirstChild("Head"):WaitForChild("VIPGui"):Destroy()
while task.wait() do
clone.CFrame=CFrame.new(origin)*CFrame.new(Result.Position)
clone.Clusters.CFrame=clone.CFrame
end
This is the raycast and the CFrame good luck.
If you need help just let me know.
local rayOrigin = humanoidRootPart.Position
local rayDirection = Vector3.new(0, -1000, 0) -- A large negative Y value to ensure it hits the ground
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
local groundPosition = raycastResult.Position
local cloneHeight = clone.Size.Y
local targetPosition = groundPosition + Vector3.new(0, cloneHeight / 2, 0)
local targetCFrame = CFrame.new(targetPosition)
clone.CFrame = targetCFrame
end