Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why Doesn't BodyVelocity move the player?

Asked by 7 years ago
script.Parent.MouseButton1Click:connect(function()
    Player = script.Parent.Parent.Parent.Parent.Parent
    Character = game.Workspace:FindFirstChild(Player.Name)
    if Character ~= nil then
        Hum = Character:FindFirstChild("Humanoid")
        if Hum ~= nil then
    Hum.Jump = true
    local new = Instance.new('BodyVelocity')
    new.Name = "Vel"
    new.Parent = Character
 Character.Vel.Velocity.Y = 150
Character.Vel.Velocity.Z = 150
wait(10)
new:Destroy()
        end
    end
end)

the output says: 14:47:34.061 - Y cannot be assigned to

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

RicheeNektar is right: "Because the Velocity.(X/Y/Z) are READ only properties of the Velocity from the player that means you can only read their values and not set them. You need to set them with the Vector3.new()".

In addition, your script parented BodyVelocity to the player's character. It should be parented to one of the character's parts such as Torso. Try adding this:

new.Velocity = Vector3.new(0,150,150)
new.Parent = Character.Torso

Notice that you can access the BodyVelocity's Velocity property directly since you established that the variable "new" is the new BodyVelocity. You need not find the velocity with "Character.Vel" each time.

Ad
Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Because the Velocity.(X/Y/Z) are READ only properties of the Velocity from the player that means you can only read their values and not set them. You need to set them with the Vector3.new() function Try this:

script.Parent.MouseButton1Click:connect(function()
    Player = script.Parent.Parent.Parent.Parent.Parent
    Character = game.Workspace:FindFirstChild(Player.Name)
    if Character ~= nil then
        Hum = Character:FindFirstChild("Humanoid")
        if Hum ~= nil then
    Hum.Jump = true
    local new = Instance.new('BodyVelocity')
    new.Name = "Vel"
    new.Parent = Character
 Character.Vel.Velocity = Vector3.new(0,150,150)
wait(10)
new:Destroy()
        end
    end
end)
0
Velocity is not a valid member of Model bossay8 8 — 7y
0
Oh forgot RicheeNektar 78 — 7y
0
Now it should work RicheeNektar 78 — 7y
0
well, there is no errors, but it doesn't fling the player. bossay8 8 — 7y
0
hm than it cant move the player by that :| RicheeNektar 78 — 7y

Answer this question