I am trying to make a wind gust in my game that launches you up into the air. Any idea on how to do it?
Here is my script currently:
function partTouched(obj) if obj.Parent:findFirstChild("Humanoid") then script.Parent:findFirstChild("Humanoid").Position = script.Parent:findFirstChild("Humanoid").Position + Vector3.new(0,1,0) end end script.Parent.Touched:connect(partTouched)
when i test this it comes up with this error
Workspace.IceFX.Script:3: attempt to index nil with 'Position'
The Humanoid doesn't have a Position
property, so you should try using the HumanoidRootPart to move the player. Also, if you only want players to touch it and be launched into the air, consider using
function partTouched(obj) local player = game.Players:GetPlayerFromCharacter(obj.Parent) if player then obj.Parent.HumanoidRootPart.Position += Vector3.new(0, 1, 0) end end script.Parent.Touched:Connect(partTouched)
However, if you're looking to launch (fling) the player into the air instead of teleporting, use the AssemblyLinearVelocity:
function partTouched(obj) local player = game.Players:GetPlayerFromCharacter(obj.Parent) if player then obj.Parent.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0, 50, 0) end end script.Parent.Touched:Connect(partTouched)