VectorForce making parts stuck in midair

Hello! For a while now i’m trying to make a simple button switch which inverts the gravity of the boxes! the boxes need to be local-sided for each player. Blue is normal gravity and red is inverted gravity.

My issue is, the boxes simply don’t go up, and only move when I touch them and freeze midair

I’ve already tried using SetNetworkOwner, but it doesn’t work since they can only be used in Server Scripts. Also looked through many posts in the devforum.

I’m trying to use VectorForce for them. But it only worked when I manually added a VectorForce into the part via playtest

The way I make the boxes local is by only unanchoring them in each client. So all the boxes are still anchored in the server

Local Script (located in StarterPlayerScripts)

-- local folder = game.Workspace.ClientObjects.GravityParts
local Players = game:GetService('Players')
local player = Players.LocalPlayer

for _, part in pairs(folder:GetDescendants()) do
	if part.Name == 'Part' then
		part.Anchored = false
	end
end

for _, v in pairs(folder:GetChildren()) do
	local button = v.Button
	local click = button.ClickDetector
	local activated = button.Activated
	
	click.MouseClick:Connect(function()
		if activated.Value == false then
			
			activated.Value = true
			button.Color = Color3.new(1, 0, 0)
			
			for _, box in pairs(v:GetChildren()) do
				if box.Name == 'Part' then
					box.Color = Color3.new(1,0,0)
					box.VectorForce.Force = Vector3.new(0,3000,0)
				end
			end
			
		else
			activated.Value = false
			button.Color = Color3.new(0, 0, 1)

			for _, box in pairs(v:GetChildren()) do
				if box.Name == 'Part' then
					box.Color = Color3.new(0,0,1)
					box.VectorForce.Force = Vector3.new(0,0,0)
				end
			end
		end
	end)
end

Help would be greatly appreciated since i’m running out of ideas =]

1 Like

Ok I fixed it, apparently it was caused because the NetworkOwnership was not from the player. So instead of unanchoring the parts each client I used a server script to insert the whole folder inside ReplicatedStorage, then on client I cloned it.
image
image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.