Can you use dragdetectors on actual players?

ive made a script that runs an animation when you press “N” and it adds a dragdetector to you, basically making you be able to be draggable, but you cant drag the player. is there any way i can make a drag detector work on a player?

script.Parent.DragStart:Connect(function()
	local animation = Instance.new("Animation")
	animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox dance emote

	local animationTrack = script.Parent.Parent.Humanoid:LoadAnimation(animation)
	animationTrack:Play()
end)

image

Put it inside startcharacterscripts so players spawn in with it.

If you need more info on hit here is the API documentation

i dont think you quite got my issue, i have a script where if you press “N” it makes you raise your hands (surrender) and sets your walkspeed to 0, adds a dragdetector to you. (inside of the humanoidrootpart, not sure if thats the issue) but the dragdetector doesnt have an effect and it doesnt let you drag the person. the goal is im trying to make people able to pick you up while surrendering.

can you show me your code, so I can look into it

local UIS = game:GetService("UserInputService")
local db = false
local dbTimer = 15

local surrendering = false
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local animation = game.StarterPlayer.StarterCharacterScripts.Surrendering.SurrenderAnimation
local dragDetector

UIS.InputBegan:Connect(function(key, inp, proc)
	if UIS:GetFocusedTextBox() then return end

	if key.KeyCode == Enum.KeyCode.N then
		if proc == true then return end
		if db == true then return end

		if surrendering == false then
			surrendering = true
			local loadanimation = humanoid:LoadAnimation(animation)
			loadanimation:Play()
			humanoid.WalkSpeed = 0

			drag = Instance.new("DragDetector")
			drag.MaxForce = 200000
			drag.Responsiveness = 7
			drag.Parent = character.HumanoidRootPart
			drag.RunLocally = true

			humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
			db = true
			task.wait(dbTimer)
			db = false
		else
			if db == true then return end
			surrendering = false

			
			loadanimation:Stop()
			humanoid.WalkSpeed = 16

			if drag then
				drag:Destroy()
			end

			humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
		end
	end
end)

and im guessing this is in a local script thats why others cant drag you.

Make a remote event and put it in replicated storage and make server script

Server Script

game.ReplicatedStorage.Surrender.OnServerEvent:Connect(function(plr, state)
	if state == true then
		local loadanimation = plr.Character.Humanoid:LoadAnimation(animation)
		loadanimation:Play()
		plr.Character.Humanoid.WalkSpeed = 0

		local drag = Instance.new("DragDetector")
		drag.MaxForce = 200000
		drag.Responsiveness = 7
		drag.Parent = plr.Character
		drag.RunLocally = true

		plr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	else
		for _,anim in pairs(plr.Character.Humanoid.Animator:GetPlayingAnimationTracks()) do
			anim:Stop()
		end
		
		plr.Character.Humanoid.WalkSpeed = 16

		if plr.Character:FindFirstChild("DragDetector") then
			plr.Character:FindFirstChild("DragDetector"):Destroy()
		end

		plr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	end
end)

Local Script

local UIS = game:GetService("UserInputService")
local db = false
local dbTimer = 15

local surrendering = false
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local animation = game.StarterPlayer.StarterCharacterScripts.Surrendering.SurrenderAnimation
local dragDetector

UIS.InputBegan:Connect(function(key, inp, proc)
	if UIS:GetFocusedTextBox() then return end

	if key.KeyCode == Enum.KeyCode.N then
		if proc == true then return end
		if db == true then return end

		if surrendering == false then
			surrendering = true
			game.ReplicatedStorage.Surrender:FireServer(surrendering )
			db = true
			task.wait(dbTimer)
			db = false
		else
			if db == true then return end
			surrendering = false
           
			
			game.ReplicatedStorage.Surrender:FireServer(surrendering)


			humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
		end
	end
end)

Network Ownership. DragDetectors will only function when the network ownership of the player is on the server.

the dragging itself works, but it doesnt drag the player, im still marking this as solution because i think i can solve this myself, thank you so much!

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