How to make a player fall/ragdoll when getting hit by a part

Ive made a beam (basically a part) that spins around. What i want to achieve is when a player gets hit by the beam, they fall over/ragdoll. How would i be able to achieve that?

I know i should create a function like part.touched:connect but i have no idea after that. ive tried doing research also on the internet but theres nobody really explaining this. So i was wondering if someone can help/tell me more about this?

1 Like

let me know if this doesn’t work

script.Parent.Touched:Connect(function(TouchedPart)
	if TouchedPart.Parent:FindFirstChild("Humanoid") then
		TouchedPart.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
	end
end)

It doesnt work sadly, no errors in the output.

2 Likes

this doesn’t really “ragdoll” but you can get a similar result i guess
i don’t really know why changeState didn’t work

script.Parent.Touched:Connect(function(TouchedPart)
	if TouchedPart.Parent:FindFirstChild("Humanoid") then
		TouchedPart.Parent.Humanoid.PlatformStand = true
		wait(1) -- change 1 to how long the character will be ragdoll for
		TouchedPart.Parent.Humanoid.PlatformStand = false
	end
end)

5 Likes

This works indeed! Thanks.

Maybe someone else would know how to change this into a ragdoll? ill leave the topic open for now.

1 Like

ChangeState should be called on the client.

1 Like

How would that look?

Char limit

local Game = game
local Workspace = workspace
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local _Part = Workspace:WaitForChild("Part")

local function OnTouched(Part)
	local Model = Part:FindFirstAncestorOfClass("Model")
	if not Model then return end
	if Model ~= Character then return end
	Humanoid:ChangeState() --Put a valid state type here.
end

_Part.Touched:Connect(OnTouched)


I get this error when trying urs, maybe a typo from me idk

As stated here, this should be performed on the client (via a local script).

1 Like

I also tried a local script, but then it returns no error but i still would not get ragdolled.

Where did you place the local script? And did you read the script’s comment?
https://developer.roblox.com/en-us/api-reference/class/LocalScript

I’ve put it inside the part but as I read ur article I should place it somewhere else? Where would that be