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)
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)
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