So i am working on a zipline script and i am having the error that you can see in that title. If someone can help me, thank you:
Heres the Script:
PartInicial = workspace.PartInicial.Parent
PartFinal = workspace.PartFinal.Parent
Click = script.Parent.ClickDetector
local TweenService = game:GetService("TweenService")
local TWI = TweenInfo.new(2, Enum.EasingStyle.Linear)
local PartInicialPosition = CFrame.new(-183.837, 0.193, 63.161) + Vector3.new(0,6,0)
local PartFinalPosition = CFrame.new(-183.837, 20.833, -6.416)
local Tween = TweenService:Create(PartInicial,TWI, {CFrame = PartFinalPosition})
local function Zipline(chr)
local HumanoidRootPart = chr.Parent:FindFirstChild("HumanoidRootPart")
HumanoidRootPart.Position = PartInicialPosition
HumanoidRootPart.Anchored = true
local Viagem = TweenService:Create(TWI)
Viagem:Play()
Viagem.Completed:Connect(Zipline)
wait(0.1)
HumanoidRootPart.Anchored = false
end
Click.MouseClick:Connect(Zipline)
Change
PartInicial = workspace.PartInicial.Parent
PartFinal = workspace.PartFinal.Parent
to
PartInicial = workspace.PartInicial
PartFinal = workspace.PartFinal
Because you’re defining them as their parent which is Workspace therefore workspace has no CFrame.
1 Like
Well it changed to this error: Workspace.PartInicial.Script:11: attempt to index nil with ‘Position’
ClickDetector.MouseClick
passes a player argument to any connected functions, not a character. So change this:
local function Zipline(chr)
local HumanoidRootPart = chr.Parent:FindFirstChild("HumanoidRootPart")
to this
local function Zipline(plr)
local HumanoidRootPart = plr.Character:FindFirstChild("HumanoidRootPart")
We solve an error and appear other:
Workspace.PartInicial.Script:11: attempt to index nil with ‘Position’
in this line
HumanoidRootPart.Position = PartInicialPosition
17kSeso
(Semih)
June 14, 2023, 6:59pm
#6
try this
HumanoidRootPart.CFrame = PartInicialPosition
same error but instead of with Position is CFrame
1 Like
17kSeso
(Semih)
June 14, 2023, 7:11pm
#9
local PartInicialPosition = CFrame.new(-183.837, 6.193, 63.161)
yes. the code is like this rn:
PartInicial = workspace.PartInicial
PartFinal = workspace.PartFinal
Click = script.Parent.ClickDetector
local TweenService = game:GetService("TweenService")
local TWI = TweenInfo.new(2, Enum.EasingStyle.Linear)
local PartInicialPosition = CFrame.new(-183.837, 0.193, 63.161) + Vector3.new(0,6,0)
local PartFinalPosition = CFrame.new(-183.837, 20.833, -6.416)
local Tween = TweenService:Create(PartInicial,TWI, {CFrame = PartFinalPosition})
local function Zipline(plr)
local HumanoidRootPart = plr.Parent:FindFirstChild("HumanoidRootPart")
HumanoidRootPart.CFrame = PartInicialPosition
HumanoidRootPart.Anchored = true
local Viagem = TweenService:Create(TWI)
Viagem:Play()
Viagem.Completed:Connect(Zipline)
wait(0.1)
HumanoidRootPart.Anchored = false
end
Click.MouseClick:Connect(Zipline)
1 Like
Yeah the errors is the same, thanks for the help
error: Workspace.PartInicial.Script:11: attempt to index nil with ‘CFrame’
17kSeso
(Semih)
June 14, 2023, 7:22pm
#13
Do you have player argument?
Im sure there is a error at this line:
local HumanoidRootPart = plr.Parent:FindFirstChild("HumanoidRootPart")
player.Parent is players
change this
local HumanoidRootPart = plr.Character:WaitForChild('HumanoidRootPart')
17kSeso
(Semih)
June 14, 2023, 7:24pm
#14
is script local script or serverscript?
PartInicial = workspace.PartInicial.Parent
-- later:
local Tween = TweenService:Create(PartInicial, TWI, {CFrame = PartFinalPosition})
The parent of the part is Workspace
, which has no CFrame property.
What do you mean?? i am bit confused
You are setting the variable to the parent of something in workspace, which gives you workspace. It’s like saying someone’s kid’s dad.
the error youre encountering is due to trying to animate a property called CFrame
on an object that doesnt have that property. The CFrame
property is typically used with objects that have a 3D transformation, such as parts or models. Based on the error message, it appears that PartInicial
or PartFinal
might not be valid parts or objects in the workspace
but they are just parts that i created, why they are not valid?
No worry guys, i aleardy fix all the bugs have a nice day
Final Code:
PartInicial = workspace.PartInicial
PartFinal = workspace.PartFinal
Click = script.Parent.ClickDetector
local TweenService = game:GetService("TweenService")
local TWI = TweenInfo.new(2, Enum.EasingStyle.Linear)
local PartInicialPosition = CFrame.new(-183.837, 0.193, 63.161) + Vector3.new(0,6,0)
local PartFinalPosition = CFrame.new(-183.837, 20.833, -6.416)
local Tween = TweenService:Create(PartInicial,TWI, {CFrame = PartFinalPosition})
local function Zipline(plr)
local HumanoidRootPart = plr.Character:FindFirstChild("HumanoidRootPart")
HumanoidRootPart.CFrame = PartInicialPosition
HumanoidRootPart.Anchored = true
local function EndTravel()
wait(0.1)
HumanoidRootPart.Anchored = false
end
local Viagem = TweenService:Create(HumanoidRootPart,TWI,{CFrame = PartFinalPosition})
Viagem:Play()
Viagem.Completed:Connect(EndTravel)
end
Click.MouseClick:Connect(Zipline)