Position cannot be assigned to

That’s it. That’s the error message. I cannot figure out why this happens.
Basically, I am making a game to test grappling hooks (How original, I know.) and I keep getting this error.

Grappling is handled in these two parts:
Client (completely functional)

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local repStore = game.ReplicatedStorage

	if (player.Character.HumanoidRootPart.Position - mouse.Hit.Position).magnitude > 100 then
		print("cant grapple D:")
		repStore.GrappleStart:FireServer(mouse.Target, mouse.Hit.Position)
		print("started grapple at " .. mouse.Hit.Position.X .. ", " .. mouse.Hit.Position.Y .. ", " .. mouse.Hit.Position.Z .. " :D")

Server (where the error is):

local repStore = game.ReplicatedStorage

repStore.GrappleStart.OnServerEvent:Connect(function(plr, mouseTgt, mouseHitPos)
	print(mouseHitPos.X .. ", " .. mouseHitPos.Y .. ", " .. mouseHitPos.Z)
	local char = plr.Character
	print("grapple recieved by server :DDD")
	local at0, at1 = Instance.new("Attachment", char["Right Arm"]), Instance.new("Attachment", mouseTgt)
	at0.Position = Vector3.new(0, -1, 0)
	at1.WorldCFrame = mouseHitPos

Everytime I click on something to create the attachments, it gives me this same error.
Any advice? Thank you.

1 Like

Could anybody help at all? I still have not solved this issue.

repStore.GrappleStart:FireServer(mouse.Target, mouse.Hit.Position) --Mouse.Hit.Position
at1.WorldCFrame = mouseHitPos -- Applying a Vector3 to a CFrame

You are trying to give a Vector3 to a CFrame, which obviously doesn’t work. Either pass through the CFrame or just replace the second line with this.

at1.WorldCFrame = CFrame.new(mouseHitPos)
OR you could do
at1.WorldPosition = mouseHitPos

Although doing it this way will mean that the rotation is not applied. Which may or may not be fine depending on what you are doing.

Next is just a personal nitpick but instead of doing

print(mouseHitPos.X .. ", " .. mouseHitPos.Y .. ", " .. mouseHitPos.Z)

You can just print the Vector3 as is:


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.