Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a character fling?

I want that if a part is touched , the player's character who touches it to fling away.(this time me) But it ain't work, it flings me but makes me invisible too

wait(3)
local debounce =  false
Player = script.Parent.Parent.Parent
n = script.Parent
mouse = Player:GetMouse()
run = game:GetService("RunService")
function pizza(mouse)
	if debounce == false then
		debounce = true
		game:GetService("Chat"):Chat(Player.Character.Head, "Sambi Genjutsu")
		Player.PlayerGui.Chakra.Clock.Value = Player.PlayerGui.Chakra.Clock.Value -200
			local x = Instance.new("Part")
			x.Shape = "Ball"
			x.Anchored = true
			x.CanCollide = false
			x.Reflectance = 0.1
			x.Transparency = 0.8
			x.TopSurface = "Smooth"
			x.BottomSurface = "Smooth"
			x.Parent = Workspace
			x.Size = Vector3.new(150, 3, 150)
			x.BrickColor = BrickColor.new("White")
			x.Name = Player.Name
			x.Parent = Workspace
			x.CFrame = Player.Character.Torso.CFrame *CFrame.new(0, -3, 0)
				x.Touched:connect(function(Part) 
    if Part.Parent:FindFirstChild("Humanoid") ~= nil  then
		script.Disabled = true
		for i = 1,35 do  
		Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -1
		Part.Parent.HumanoidRootPart.Position = Part.Parent.HumanoidRootPart.Position +Vector3.new(5, 10, 5)
		wait(0.05)
		end
		wait(60)
		script.Disabled = false
    end
	wait(0.025)
end)
			game.Debris:AddItem(x, 40)
	end
	wait(60)
	debounce = false
end


function onSelected(mouse)
	mouse.Button1Down:connect(function() pizza(mouse) end)
end

n.Selected:connect(onSelected)

1 answer

✓ Accepted answer

To make an object fling, all you have to do is change the Velocity of the object i.e.

player.Character.Torso.Velocity = Vector3.new(math.random(-1000,1000),1000,math.random(-1000,1000))

to make the player fling when touched do

script.Parent.Touched:connect(function(t) -- t = part touched
if t.Parent:FindFirstChild("Humanoid") then -- detects if t's parent has a humanoid
t.Parent.Torso.Velocity = Vector3.new(math.random(-1000,1000),1000,math.random(-1000,1000))
end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.