Currently I am trying to use an object value, everything works fine even the check print but when I try use the object value in MoveTo for the position it doesnt work, but if I substitute it with the actual position it works fine. Here are some screenshots of output:
Here’s the script: local ui = script.Parent
local frame = ui:WaitForChild(“Frame”)
local left = frame:WaitForChild(“Left”)
local right = frame:WaitForChild(“Right”)
local cName = frame:WaitForChild(“CarName”)
local CarModel = game.ReplicatedStorage.Cars
local index = 1
script.Parent.Frame.Right.MouseButton1Click:Connect(function()
print("clicked")
if CarModel:FindFirstChild("Car"..index+1) then
index += 1
else
index = 1
end
cName.Text = script:FindFirstChild("Car"..index).Value
print(index)
end)
script.Parent.Frame.Left.MouseButton1Click:Connect(function()
print("clicked")
if CarModel:FindFirstChild("Car"..index-1) then
index -= 1
else
index = 2
end
cName.Text = script:FindFirstChild("Car"..index).Value
print(index)
end)
script.Parent.Frame.CarName.MouseButton1Click:Connect(function()
print(index)
local car = CarModel:FindFirstChild("Car"..index)
local val = script.Parent.objval.Value
game:GetService("ReplicatedStorage"):WaitForChild("aAsTnjhgU"):FireServer(car, val, pos)
end)