What is wrong with this script?

Hi, I’m making a game that I’m about to launch but there’s a script that isn’t working:

while wait(0.001) do
	local ballposition = game.Workspace.ball.Position.Y
	script.Parent.Position.Y = ballposition
end

this script is used to change the height of a part according to the height of another part but it doesn’t work, my output says: “Y cannot be assigned to - Server - Script”

does anyone know how to solve?

local Parent = script.Parent
local Ball = workspace.ball

while true do task.wait()
    Parent.Position = Vector3.new(
        Parent.Position.X,
        Ball.Position.Y,
        Parent.Position.Z
    )
end
1 Like

this script don’t work for me.

I forgot to add a comma, my bad
it is edited

still says: " Y cannot be assigned to - Server - Script"

that error shouldn’t be happening in my code
can I see what code you have right now?

I was using the code:

while wait(0.001) do
	local ballposition = game.Workspace.ball.Position.Y
	script.Parent.Position.Y = ballposition
end

you didn’t even use the code I sent you…

I used yours but it gives the same error

I’m guessing that since the error is “cannot be assigned to Server Script”, script.Parent won’t work since script.Parent will reference the ServerScriptService.

I’ll see if it works on ServerScriptService

What? I said it won’t work if its under ServerScriptService.

oh, my script was not in ServerScriptService

I’m not even assigning y to anything directly
I am changing the Position using a Vector3

I don’t see how my code gives that error at all

I see a little bit in the script and found that I had put it in the wrong place, it really works

programming is harder than I thought