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?
script.Parent.Touched:Connect(function(TouchedPart)
if TouchedPart.Parent:FindFirstChild("Humanoid") then
TouchedPart.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
end
end)
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)
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)