So basically I want to make a weapon that flings you and ragdolls you for a few seconds How would I do this?
I already have this
local power = 5
script.Parent.Activated:Connect(function()
end)
I haven't tried anything yet as I don't know how I would do this.
Here are the two main functions you may want to consider trying for your weapon:
local function fling(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:ChangeState(11)
local rootPart = character:FindFirstChild("HumanoidRootPart")
if rootPart then
local force = Vector3.new(math.random(-100, 100), math.random(50, 100), math.random(-100, 100))
rootPart.Velocity = force
end
end
end
local function ragdoll(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
local rootpart
if humanoid then
humanoid:ChangeState(11)
rootpart = humanoid.RootPart
end
if not rootpart then
rootpart = character.AssemblyRootPart
end
if rootpart then
rootpart.Velocity = Vector3.new(math.random(-100, 100), math.random(50, 100), math.random(-100, 100)) * 10
end
end
If you are making weapons, use UserInputService
and WorldRoot:Raycast
for handling mouse and ray-casting related operations.
For melee weapons I would suggest just sticking to the tool as you are already doing. You can set cooldowns with a debounce
variable and play animations on activation (depending on whether or not the cooldowns have completed).
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://0" -- My animation ID.
local AnimationTrack = Animator:LoadAnimation(Animation)
AnimationTrack.Priority = Enum.AnimationPriority.Action -- Change the priority.
AnimationTrack:Play(.1) -- .1 Being the time between current animation states & the animation track's initial playing state.
There are various ways to implement this, my game uses a cache-based weapon system which stores the guns for later use once they've been equipped once.
Mine is a bit advanced but it gives an example of what you could do with just ray-casting & user input.