Fling Script Not Working

Hello. I am trying to make a script so that when someone says, “Yeet” they get flung. I can’t figure out what’s wrong with the script though. Could someone help me?

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message == "Yeet" then
			script.Parent.Touched:Connect(function(touch)

				if touch.Parent:FindFirstChild("HumanoidRootPart") == nil then return end 

				local HRP = touch.Parent:FindFirstChild("HumanoidRootPart") 

				local Humanoid = touch.Parent:FindFirstChild("Humanoid") 

				Humanoid.Sit = true

				local BodyVelocity = Instance.new("BodyVelocity", HRP) 
				BodyVelocity.Velocity = Vector3.new(0,200,0) 

				wait(1)

				BodyVelocity:Destroy() 
			end
		end)
	end)
1 Like

What is with the Touched event? Is that necessary to the script?

1 Like

No I don’t think so. I followed a tutorial cause I am still learning.
(is it causing a problem with the script?)

1 Like

Just remove the touched event and replace the script with this:

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message == "Yeet" then
	        local char = player.Character or player.CharacterAdded:Wait()
            local hrp = char:WaitForChild("HumanoidRootPart")
            local humanoid = char:WaitForChild("Humanoid")
            humanoid.Sit = true
            local BodyVelocity = Instance.new("BodyVelocity", hrp) 
	        BodyVelocity.Velocity = Vector3.new(0,200,0) 
	        wait(1)
            BodyVelocity:Destroy() 
             end
		end)
	end)

1 Like

tysm This SO helpful <3 addingthis cause not enough characters lol

1 Like

Still not working for some reason
(at least in test place)

1 Like

Is the script a local script or a normal script?

It’s in ScriptServerStorage so normal I think

Is it recieving errors in the console?


image

Oh add do this then

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message == "Yeet" then
	        local char = player.Character or player.CharacterAdded:Wait()
            local hrp = char:WaitForChild("HumanoidRootPart")
            local humanoid = char:WaitForChild("Humanoid")
            humanoid.Sit = true
            local BodyVelocity = Instance.new("BodyVelocity", hrp) 
	        BodyVelocity.Velocity = Vector3.new(0,200,0) 
	        wait(1)
            BodyVelocity:Destroy() 
             end
		end)
	end)

Its because you forgot to put the end for the if message == “Yeet” part

Works Now. Thanks. Any recommendation for how far to make it fling? currently just hops me up into the air LOL

Just increase the velocity vector3 like this:

 BodyVelocity.Velocity = Vector3.new(0,200,100) 

Alr thanks.
:> this was very helpful!

oh yeah, one last thing, how would I make it so it works regardless of capitalization ?

Do this:

That makes every capitalization of the word execute the code.

So replace the If message ==?
sorry for being so annoying :<

Yea you do that, just replace it with the code I provided

1 Like

Alr. Thanks for the help, and for being patient. You’ve earned a follow :>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.