Making a script where when you click the Key bind, it holds the player in the air, and when you click again it throws them to the direction that you want. I’ve done it for a just mouse button but I’m trying to make it Key bind and it’s not working.

Local Script

wait()

  

local Player = game:GetService("Players").LocalPlayer 

local char = Player.Character

local Mouse = Player:GetMouse()

local cooldown = 0

local replicatedstorage = game:GetService("ReplicatedStorage")

  

  

  

script.Parent.Equipped:Connect(function(mouse,key)

    mouse.KeyDown:Connect(function()

	    local key = key:lower()

	    if key == "h" then

	    local hum = 		mouse.Target.Parent:FindFirstChild("Humanoid")

	    if hum then
	

		    script.Parent.NewGrab:FireServer(hum,Mouse.hit,Player.name)
		    game.Players.LocalPlayer.Character.Humanoid.JumpPower = 51




mouse.Button1Down:Connect(function()

    if game.Players.LocalPlayer.Character.Humanoid.JumpPower == 51 then

	    local Hit = mouse.hit

	    game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50

	    script.Parent.NewThrow:FireServer(Hit)

	    script.Parent.Sound:Play()

	    wait(2)

	    game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50

			    end
    
		    end)

	    end

	  end

    end)

end)

Server Script

script.Parent.NewGrab.OnServerEvent:Connect(function(player,hum)
    if hum then
	    local BP = Instance.new("BodyPosition")
	    BP.MaxForce = Vector3.new(9999999,9999999,9999999)
	    BP.Parent = hum.Parent.UpperTorso
	    BP.Position = player.Character.UpperTorso.Position + Vector3.new(0,6,-3)

		script.Parent.NewThrow.OnServerEvent:Connect(function(player,Hit)
		    BP.Position = player.Character.Head.Position + (Hit.p - player.Character.Head.Position).unit * 65
		    wait(0.5)
		    BP:Destroy()
	    end)
	    wait(3)
	    BP:Destroy()
    end
end)

1 comment

0

I have done something similar in the past im proud what it turned.