-
What do you want to achieve? Keep it simple and clear!
I want make this script part work correctly, and return side on which mouse pointing. -
What is the issue? Include screenshots / videos if possible!
Issue appear after raycast update. Before it work correctly, but now script return nil instead of side. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I was trying change mouse.Target into Raycasting, and trying add wait(). Yes, i try find simular situations. I don’t find them
Issue start appear after Raycasting update, which increase raycating speed and distance. Before that update script worked without errors.
function BuildMod.CalcSurface(Part, mouse, Play) --Part == mouse.Target, mouse == mouse.Hit.p, Play == Player.Character
local PartCFrame = Part.CFrame
local XS = Part.Size.X
local YS = Part.Size.Y
local ZS = Part.Size.Z
--here i create 6 parts on each side of mouse.Target part
local PartRight = Instance.new("Part", workspace)
PartRight.Color = Color3.fromRGB(255, 0, 0)
PartRight.Size = Vector3.new(0.1,YS,ZS)
PartRight.Anchored = true
PartRight.CFrame = Part.CFrame:ToWorldSpace(CFrame.new(XS / 2, 0, 0))
PartRight.Name = "Right"
local PartFront = Instance.new("Part", workspace)
PartFront.Color = Color3.fromRGB(0, 0, 255)
PartFront.Size = Vector3.new(XS,YS,0.1)
PartFront.Anchored = true
PartFront.CFrame = Part.CFrame:ToWorldSpace(CFrame.new(0, 0, -ZS / 2))
PartFront.Name = "Front"
local PartTop = Instance.new("Part", workspace)
PartTop.Color = Color3.fromRGB(0, 255, 0)
PartTop.Size = Vector3.new(XS,0.1,ZS)
PartTop.Anchored = true
PartTop.CFrame = Part.CFrame:ToWorldSpace(CFrame.new(0, YS / 2, 0))
PartTop.Name = "Top"
local PartBack = Instance.new("Part", workspace)
PartBack.Color = Color3.fromRGB(0, 255, 255)
PartBack.Size = Vector3.new(XS,YS,0.1)
PartBack.Anchored = true
PartBack.CFrame = Part.CFrame:ToWorldSpace(CFrame.new(0, 0, ZS / 2))
PartBack.Name = "Back"
local PartLeft = Instance.new("Part", workspace)
PartLeft.Color = Color3.fromRGB(255, 0, 255)
PartLeft.Size = Vector3.new(0.1,YS,ZS)
PartLeft.Anchored = true
PartLeft.CFrame = Part.CFrame:ToWorldSpace(CFrame.new(-XS / 2, 0, 0))
PartLeft.Name = "Left"
local PartBottom = Instance.new("Part", workspace)
PartBottom.Color = Color3.fromRGB(255, 255, 0)
PartBottom.Size = Vector3.new(XS,0.1,ZS)
PartBottom.Anchored = true
PartBottom.CFrame = Part.CFrame:ToWorldSpace(CFrame.new(0, -YS / 2, 0))
PartBottom.Name = "Bottom"
--There was local mouseTRT = mouse.Target (mouse was Player:GetMouse())
local RayOrigin = workspace.CurrentCamera.CFrame.Position
local RayDirection = mouse
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Play}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local mouseTRT = workspace:Raycast(RayOrigin, RayDirection, raycastParams)
--
local ret
--Checking side
if mouseTRT == PartRight then
ret = "Right"
elseif mouseTRT == PartLeft then
ret = "Left"
elseif mouseTRT == PartFront then
ret = "Front"
elseif mouseTRT == PartBack then
ret = "Back"
elseif mouseTRT == PartTop then
ret = "Top"
elseif mouseTRT == PartBottom then
ret = "Bottom"
else
--I receiving this messages bc mouseTRT == nil (idk why)
warn("Something going wrong!")
end
--Removing Parts
PartRight:Destroy()
PartFront:Destroy()
PartLeft:Destroy()
PartBack:Destroy()
PartTop:Destroy()
PartBottom:Destroy()
return ret
end
Sorry if i make mistakes, this’s my first topic. (and i’m not very good in English)