Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why dose't this work? (.Value = ""..part.Position.."") Please Help

Asked by
Dr_Doge 100
9 years ago

So im trying to make a "Save Blocks" Script, but i came across this problem.

when I run the script/press the button, inside Player, theres a Value called Save and in Save theres a Value Called Part, and inside Part theres a Value called pos, but pos has no value, so im gessing that .Value = ""..part.Position.."" is wrong. Can someone explain why it wont work?

local Gui = script.Parent
local Player = Gui.Parent.Parent.Parent
local Char = Player.Character
local part = game.Workspace:FindFirstChild("Part")

function onClicked()

    local save = Instance.new("StringValue", Player)
    save.Name = "Save"

    while true do
        wait()
        if part ~= nil then
            local savepart = Instance.new("StringValue", save)
            savepart.Name = "Part"

            local savepartpos = Instance.new("StringValue", savepart)
            savepartpos.Name = "pos"
            savepartpos.Value = ""..part.Position..""

            local savepartrot = Instance.new("StringValue", savepart)
            savepartrot.Name = "rot"
            savepartrot.Value = ""..part.Rotation..""

            local savepartsize = Instance.new("StringValue", savepart)
            savepartsize.Name = "size"
            savepartsize.Value = ""..part.Size..""

            part:remove()
        end

    end


end

Gui.MouseButton1Click:connect(onClicked)



0
o hey i think i found my problem.. I think i need to do X Y and Z seperatly Dr_Doge 100 — 9y

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

If you want a string representation, you should just use tostring(part.Position).

Concatenation has to be specifically defined -- it doesn't automatically turn objects into strings when concating with a string. Since it wasn't for Vectors, you get an error.


It makes a lot more sense to use Vector3Values, though, since that way you can actually get the value back later without doing an excessive amount of work.

Ad

Answer this question