Hi again
I want to make this part slid back and fourth but it is getting a error saying z does not exist.
while true do
script.Parent.CFrame.Position.Z = 102.983
wait (.8)
script.Parent.CFrame.Position.Z = 39.783
end
--- We want here 1st 185.629, 10.5, 102.983
--- We want here 2nd 185.629, 10.5, 39.783
You can’t set XYZ separately as they’re read only, you have to do it like this
while true do
script.Parent.Position = Vector3.new(185.629,10.5,102.983)
wait (.8)
script.Parent.Position = Vector3.new(185.629,10.5,39.783)
end
--- We want here 1st 185.629, 10.5, 102.983
--- We want here 2nd 185.629, 10.5, 39.783
Also wait, why are you getting the CFrame and then the Position? You can reference it immediately via script.Parent.Position
It works with 1 edit
while true do
wait(.8)
script.Parent.Position = Vector3.new(185.629,10.5,102.983)
wait (.8)
script.Parent.Position = Vector3.new(185.629,10.5,39.783)
end
--- We want here 1st 185.629, 10.5, 102.983
--- We want here 2nd 185.629, 10.5, 39.783
But its not sliding the part like back and fourth it just disappears then comes back to the right position
The of course repeats.
You need to tween it then
local ts = game:GetService("TweenService")
local part = script.Parent
local info = TweenInfo.new(0.8)
local tween1 = ts:Create(part,info,{Position = Vector3.new(185.629,10.5,102.983)})
local tween2 = ts:Create(part,info,{Position = Vector3.new(185.629,10.5,39.783)})
while true do
wait(0.8)
tween1:Play()
wait(0.8)
tween2:Play()
end
--- We want here 1st 185.629, 10.5, 102.983
--- We want here 2nd 185.629, 10.5, 39.783
Forgot to close those dictionaries
1 Like