How do I awake my parts, they are floating mid air after my car exploded from a mine.
I would try 2 things:
- Set parts network owner to server
- Add added gravity vector force on each part
Curious what is the view on the serverside? Is the explosion client sided or server?
Umm, Can you explain in a bit more in detail?
how do I set the network owner to server?
Part:SetNetworkOwner(null)
It will set the network owner of the part to the server
local function ServerPartOwnership(part)
if part:CanSetNetworkOwnership() then
part:SetNetworkOwner(nil)
end
end
Make sure to run this on the server
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.
Oh, Its normal on the server.
The problem is on the client side
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)
You define the ServerPartOwnership function but never use it.
Not sure where to put it
I dont know where to call the function
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)
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)
Its not working, still freezes in the air
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?