Iam having some collisions problems with my skill (read the post to understand please)

Bassicaly the skill create a sphere that trap players (caster Will be traped too but he Will have advantage inside)

https://gyazo.com/b268d6bc798d278bea924fab5d1da0ed

But have some problems, the problem is the collision issue, I don’t want the sphere to enter any building, mountain or into another sphere, I tried to use cancollide but it’s not possible to use cancolide and anchored together (if I don’t use anchored the sphere will fall …), so I need a way for the sphere to appear in a place with enough space

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DarkZone = ReplicatedStorage.Skills.Impure.DarkZone.Remotes.DarkZone
local Meshes = script.Meshes
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local trainingm = require(game.ServerStorage.TrainingFiles.TrainingModule)
	
	
	
local function darkZoneF(player)
	
    local interval = 0	
	local usingSkill = Instance.new("BoolValue")
	local colission = false
	usingSkill.Name = "usingSkill"
	usingSkill.Value = true
	usingSkill.Parent = player
	print("DARK ZONE")
	
	local Character = player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
	local b = Instance.new("BodyPosition")
	local bv = Instance.new("BodyVelocity")
	
	local Track = Humanoid:LoadAnimation(script.DZone1)
	local ValueA = Track.Length
	Track:Play()
	
	
	local Folder = Instance.new("Folder",workspace)
	Folder.Name = player.Name.." DZone"
	Folder.Parent = workspace
	
	local mDark = Meshes:WaitForChild("MDarkZone"):Clone()
	mDark.CFrame = Character:WaitForChild("LeftHand").CFrame * CFrame.new(0.8,0,-0.1)
	mDark.Parent = Folder
	
	mDark.Touched:Connect(function(hit) end)
	
	
	local weld = Instance.new("WeldConstraint")
	weld.Parent = Folder
	weld.Part0 = mDark
	weld.Part1 = Character:WaitForChild("LeftHand")
	
	wait(1)
	
	local goal = {}
	goal.Transparency = mDark.Transparency - 1
	local info = TweenInfo.new(0.2)   
	local tween = TweenService:Create(mDark,info,goal)
	tween:Play()
	
	local Track = Humanoid:LoadAnimation(script.DZone2)
	Track:Play()
	
	HumanoidRP.Anchored = false
	
	wait(2)
	
	weld:Destroy()
	
	
	
	local goal = {}
	goal.Size = mDark.Size + Vector3.new(128, 128, 128)
	goal.CFrame = mDark.CFrame + Vector3.new(0,128,0)
	local info = TweenInfo.new(0.2)   
	local tween = TweenService:Create(mDark,info,goal)
	tween:Play()
	
	tween.Completed:Wait()
	
	mDark.CanCollide = true

	 while mDark.Parent do
		  local amount = 0
		  for _, part in ipairs(mDark:GetTouchingParts()) do
			 amount = amount + 1
		  end
		  if amount == 0 then
			print("NOT TOUCHING")
			HumanoidRP.CFrame = mDark.CFrame
			mDark.Anchored = true
		  else
			print("TOUCHING")
			mDark.Anchored = false
			interval = 0
		  end
		 wait(0.3)
		 interval = interval + 1
		 if interval > 3 then
			break
		 end
	  end	
	
	
	
	
	wait(1)
	b:Destroy()
	
	
		
	
end


local function checkEnable(player)
	if trainingm.GetTraining(player)["Endurance"] ~= "No" or trainingm.GetTraining(player)["Mind"] == "Auto" or player:FindFirstChild("usingSkill") then
		
	else
		player.Character:WaitForChild("HumanoidRootPart").Anchored = true
		darkZoneF(player)
	end
		
end

DarkZone.OnServerEvent:Connect(checkEnable)

I tried make that while to anchor the part when part stop touching, but this made the skill very ulgy when appear, see

https://gyazo.com/9bfe437bd462b8297cdf5fa677fa19a7

**I don’t know if you noticed it but it appears inside the other sphere and only after it leaves it, it gets very ugly and can bug (sometimes it goes into the sphere), I want to avoid that: **

https://gyazo.com/7e9e05062f402d018ee8401e9ca9f063

2 Likes

Have you looking into Collision Filtering via Collision Groups? You can choose what and what not to collide with.

FYI: If you wanted to ignore the Roblox terrain then you should add workspace.Terrain to the CollisionGroup that you’ll set the collisions off to.

1 Like

?? this is contrary to what I want, I simply want the sphere to appear somewhere with nothing to prevent the sphere from getting stuck inside something (like another sphere for example)

You’re trying to make it not collide with the buildings, mountains or other spheres? Or am I getting the wrong end of the stick?

I just want the sphere not to get stuck in anything, it must appear in a place with enough space for it

1 Like

I’m sure you can turn on both Anchor and CanCollide at the same time, I mean theres no reason to why it wouldn’t work like that.

I suggest you try reducing the size of the spheres so you can see better what they are colliding with.

Why don’t you check the region3 first after placing down the sphere and check if smth is inside? (Terrain or parts).

Check this is okay but how i will know where the part should be placed ?

I would make it in a loop and check your surroundings and if it hitting something, move +50 on the x or y or z axes.

Please do not create duplicate topics