String expected, got vector script bug help

My code is

``Function brick()
Wait(1)
Script.Parent.Text = “loading… 1”
Wait(1)
Script.Parent.Text = “loading… 2”
Wait(1)
Script.Parent.Text = “loading… 3”
Script.Parent.Text = “Error Loading”

Local part = Instance.new(“Part”)
Part.Position = game.workspace
Local PartPos = “1,1,1”
Part.Position = Vector3.new(PartPos)
Script.Parent.Tex = Part.Position
End
Brick()``

The error is
Players.SakDevRblx.PlayerGui.TextGui.Script:14 invalid arguement #3 (string expected, got vector 3)

Can somone please help.
I pefer if you give me a working script as well or at least tell me how to get one without to much complex stuff

The script
-creates a brick on spawn
-has a gui that tells player where brick position is



Vector3 values do not have strings in them.

Replace this:

With this:

Part.Position = Vector3.new(1,1,1)
1 Like

It still has same error. No strings
Edit: on line 13
Error = script:13:invalud arguement #3 (string expected, got vector)

Try this:

function brick()
    for i = 1,3 do
        wait(1)
        script.Parent.Text = "loading... "..i
    end
    
    script.Parent.Text = "error loading"
    local Part = Instance.new("Part")
    Part.Position = Vector3.new(1,1,1)
    Part.Parent = workspace
    
    script.Parent.Text = tostring(Part.Position.X) .. tostring(Part.Position.Y) .. tostring(Part.Position.Z)
end

brick()
1 Like

I wana feel like i did something tho
Can i just copy last part and relace
Script.parent.text = pos?

Are you sure you are still getting any errors? I fixed your code a little bit more for you so hopefully this works.

function brick()
	for t = 1, 3 do
		script.Parent.Text = "loading... "..tostring(t)
		wait(1)
	end
	script.Parent.Text = “Error Loading”

	local part = Instance.new(“Part”)
	part.Position = game.workspace
	part.Position = Vector3.new(1,1,1)
	script.Parent.Text = part.Position
end

Brick()
1 Like

I belive stating straight up: script.Parent.Text = Part.Position is incorrect. Try: script.Parent.Text = tostring(Part.Position) This should work.

3 Likes

Nothing wrong with learning from someone with more experience, but I see what you’re saying. The reason Line 14 is erroring is because you’re trying to set the Text property (a string) to a Vector3 value.

Change just Line 14 of your code to this:

script.Parent.Text = tostring(Part.Position.X) .. tostring(Part.Position.Y) .. tostring(Part.Position.Z)

Why does this change work? It’s because we’re just taking the individual values of the Vector3 (1,1,1) in this case and using the built in tostring() method to turn it into a string value. Since it’s a string, the .Text property won’t error.

1 Like

Thanks i feel like everyone helped but yoh gave most clear answer

Didn’t even realize this was a thing (tostring(V3)), best answer imo.

1 Like

Very well, I hope this helped you! Have a phenomenal day/night!

1 Like

since you can concatenate numbers, you don’t need to use tostring() here

Disregard this post by me LOL!

This text will be blurred.

I knew about this but included it in just for learning purposes. I rarely ever even use tostring() in all honesty.

Also, make sure to solution me so people are aware this issue is solved! (:

function brick()
	task.wait(1)
	script.Parent.Text = "loading... 1"
	task.wait(1)
	script.Parent.Text = "loading... 2"
	task.wait(1)
	script.Parent.Text = "loading... 3"
	script.Parent.Text = "Error Loading"

	local Part = Instance.new("Part")
	Part.Parent = workspace
	local PartPos = Vector3.new(0, 0, 0)
	Part.Position = PartPos
	script.Parent.Text = tostring(Part.Position)
end

brick()

You’re incorrectly capitalising a lot of things, also to reference the workspace you can either use “game.Workspace” or “workspace” bare in mind that both are case sensitive (so you must type them exactly as I have). I’ve also replaced “wait()” for “task.wait()” as “wait()” is going to be deprecated soon.

Snipping this post, nothing to see here.

Snipping this post, nothing to see here.