How do I prevent my parts from falling asleep mid air?

How do I awake my parts, they are floating mid air after my car exploded from a mine.

https://gyazo.com/8fdd5e2f02860ab14ac749b64ab74207

6 Likes

I would try 2 things:

  1. Set parts network owner to server
  2. Add added gravity vector force on each part

Curious what is the view on the serverside? Is the explosion client sided or server?

3 Likes

Umm, Can you explain in a bit more in detail?

how do I set the network owner to server?

3 Likes

Part:SetNetworkOwner(null)

It will set the network owner of the part to the server

4 Likes
local function ServerPartOwnership(part)
		if part:CanSetNetworkOwnership() then
			part:SetNetworkOwner(nil)
		end
	end

Make sure to run this on the server

4 Likes

So I found something out. It only happens when I’m in the car. When I jump out the car while its moving and hits the mine everything works just fine. When I’m in the car and the car hits the mine things freeze in the air.

2 Likes

Oh, Its normal on the server.

The problem is on the client side

2 Likes

I think I’ve done it wrong

Here is my code:

local mine = script.Parent
local Debris = game:GetService("Debris")
local whiteListedParts = {mine}

local sound = script.Parent.BoomSound
local DEBOUNCE = false
mine.Transparency = .9

mine.Touched:Connect(function(hit)
	local minePosition = mine.CFrame.Position
	
	if hit:IsA("Terrain") then
		return;
	end;
	
	if not DEBOUNCE then
		DEBOUNCE = true
		
		sound:Play()
		local boom = Instance.new("Explosion")
		boom.ExplosionType = Enum.ExplosionType.NoCraters
		boom.BlastPressure = 300000
		boom.BlastRadius = 15
		boom.Parent = mine
		boom.Position = minePosition
		boom.Visible = true
		
		boom.Hit:Connect(function(part: BasePart, _)
			part.Anchored = (part == mine) or false
			
			local function ServerPartOwnership(part) -- setting network part ownership (not working)
				if part:CanSetNetworkOwnership() then
					part:SetNetworkOwner()
				end;
			end;
			
			if hit.Parent:FindFirstChild("Humanoid") then
				hit.Parent.Humanoid.Health = 0
			end;
			if not table.find(whiteListedParts, part) then
			Debris:AddItem(part,20)
			return end
		end)
		
		local light = Instance.new("PointLight")
		light.Parent = mine
		light.Brightness = 10
		light.Range = 12
		light.Color = Color3.new(0.942306, 0.0528725, 0)
		light.Enabled = false
		
		task.wait(0.4)
		
		light.Enabled = false
		
		mine.Transparency = 1
		
		sound.Ended:Wait()
		
		wait(5)
		
		mine.Transparency = 0.9
		
		DEBOUNCE = false
	end
end)

2 Likes

You define the ServerPartOwnership function but never use it.

2 Likes

Not sure where to put it

I dont know where to call the function

2 Likes

I’m getting this error aswell.

  15:01:47.130  Workspace.Mine.MineScript:32: attempt to index nil with 'CanSetNetworkOwnership'  -  Server - MineScript:32
  15:01:47.130  Stack Begin  -  Studio
  15:01:47.130  Script 'Workspace.Mine.MineScript', Line 32 - function ServerPartOwnership  -  Studio - MineScript:32
  15:01:47.130  Script 'Workspace.Mine.MineScript', Line 42  -  Studio - MineScript:42
  15:01:47.130  Stack End  -  Studio

My code:

boom.Hit:Connect(function(part: BasePart, _)
			part.Anchored = (part == mine) or false
			
			local function ServerPartOwnership(part)
				if part:CanSetNetworkOwnership(part) then
					part:SetNetworkOwner()
				end;
			end;
			
			if hit.Parent:FindFirstChild("Humanoid") then
				hit.Parent.Humanoid.Health = 0
			end;
			if not table.find(whiteListedParts, part) then
				Debris:AddItem(part,20)
				ServerPartOwnership()
			return end
		end)
2 Likes
boom.Hit:Connect(function(part: BasePart, _)
			part.Anchored = (part == mine) or false
			
			local function ServerPartOwnership(part)
				if part:CanSetNetworkOwnership(part) then
					part:SetNetworkOwner()
				end;
			end;
			
			if hit.Parent:FindFirstChild("Humanoid") then
				hit.Parent.Humanoid.Health = 0
			end;
			if not table.find(whiteListedParts, part) then
				Debris:AddItem(part,20)
				ServerPartOwnership(part)
			return end
		end)
3 Likes

Its not working, still freezes in the air

2 Likes
1 Like

I’ve downloaded the file but I dont know what to do with the module script, do I require the module script in my explosion script?

1 Like