Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Fixed] Click plane isn't working well?

So I have scripted a click plane, but when I click a part that isn't the ship it just stops mid-air.

Server

local tool = script.Parent

tool.ChangeVelocity.OnServerEvent:Connect(function(plr, mouseP)
	if plr.Character then
		local torso = plr.Character.Torso
		if torso:FindFirstChild("BodyPosition") then
			torso.BodyPosition.Position = mouseP
			--torso.BodyGyro.CFrame = CFrame.new(torso.Position, mouseP)
		else
			local bodyPosition = Instance.new("BodyPosition")
			local bodyGyro = Instance.new("BodyGyro")
			--bodyGyro.CFrame = CFrame.Angles(mouseP.X, mouseP.Y, mouseP.Z)
			bodyPosition.MaxForce = Vector3.new(350,350,350)
			bodyPosition.P = 40
			bodyPosition.Position = mouseP
			bodyPosition.Parent = torso
			--bodyGyro.Parent = torso
		end
	end
end)

tool.DestroyVelocity.OnServerEvent:Connect(function(plr)
	if plr.Character then
		plr.Character.Torso.BodyPosition:Destroy()
		--plr.Character.Torso.BodyGyro:Destroy()
	end
end)

Local

local tool = script.Parent

tool.Equipped:Connect(function(mouse)
	local plr = game.Players.LocalPlayer
	local char = plr.Character
	local cam = workspace.CurrentCamera
	
	workspace.Gravity = 0
	mouse.Button1Down:Connect(function()
		if not char then return end
		mouse.TargetFilter = char.Humanoid.SeatPart.Parent.Body
		tool.ChangeVelocity:FireServer(mouse.Hit.p)
	end)
	tool.Unequipped:Connect(function()
		tool.DestroyVelocity:FireServer()
		workspace.Gravity = 196.2
	end)
end)

1 comment

0

this is a repost because no-one responded to my last post

1 answer

Fixed it by making the targetfilter the entire workspace

This discussion is preserved as it was. New answers, comments, and votes are closed.