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

Why can't this LocalScript access the Player's Torso?

Asked by 4 years ago

I'm trying to teleport the player to a position so the animation runs correctly. I'm trying to get the Player Torso but it says the torso is not a valid member of Model. Please Help!

local UI = script.Parent
local Seed = game.Players.LocalPlayer.Inventory.Seeds.Cabbage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CabbagePlanting = ReplicatedStorage:WaitForChild("PlantCabbageEvent")
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

if Seed.Value >= 1 then
    UI.Visible = true
end

Seed:GetPropertyChangedSignal("Value"):Connect(function()
    if Seed.Value >= 1 then
        UI.Visible = true
    elseif Seed.Value == 0 then
        UI.Visible = false
    end
end)

script.Parent.Frame.Plant.MouseButton1Click:Connect(function(player)
    script.Parent.Parent.Parent:TweenPosition(UDim2.new(1.319, 0, 0.291, 0), "Out", "Quint", 1, false, nil)
    local track = humanoid:LoadAnimation(script.Animation)
    character.Torso.CFrame = CFrame.new(game.Workspace.Crops1.Position.X + 3, game.Workspace.Crops1.Position.Y, game.Workspace.Crops1.Position.Z) 
    track:Play()
    print("PlayAni")
    CabbagePlanting:FireServer()
    wait(1)
    track:Stop()
    print("StopAni")
end)

1 answer

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

It says that because there are 2 torsos in a character, one called upper torso and one called lower torso. I would recommend using the HumanoidRootPart because it is basically both torsos merged together and it's the primary part.

Ad

Answer this question