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

Why is my 'Position' command erroring?

Asked by 9 years ago

I have checked, and rechecked what the problem could be, but sadly I do not see any errors in the code I am using, and the Output says 17:41:52.170 - Workspace.XAdminCommandsX's Admin V1:466: Workspace.XAdminCommandsX's Admin V1:464: attempt to concatenate local 'POS' (a userdata value) 17:41:52.171 - Script 'Workspace.XAdminCommandsX's Admin V1', Line 466 - global Chat 17:41:52.173 - Stack End 'This is apart of a bigger script, and yes, this is my script', but, I do not understand what is means by attempt to concatenate local 'POS' (a userdata value) when it is supposed to get the Position of a 'Model' type instance, when I test this line of code, print(game.Players.Player1.Character:GetModelCFrame().p), the Output says 0.00458194362, 2.93354607, -0.703989267, the exact position of where I am standing in the Studio Mode, so, I am confused to why it won't work with the command version, here is the script;

if msg:lower():sub(1,4+#Prefix) == Prefix.."pos " then --Line 458
local plrz = GetPlr(plr,msg:sub(5+#Prefix))
for i,v in pairs(plrz) do
coroutine.wrap(function()
if v and v.Character and v.Character:IsA("Model") and v.Character:FindFirstChild("Torso") and v:FindFirstChild("PlayerGui") then
local POS = v.Character:GetModelCFrame().p --Line 466, this is where the error is coming from apparently [Yes, I have tried 'v.Character.Torso.CFrame' and 'v.Character.Torso.Position' aswell, but the same error]
Hint(v.Name.."'s Character position is "..POS,Services.Players:GetPlayers(),"SYSTEM MESSAGE")
end
end)()
end
end --Line 468

I am sorry if this Question is considered Off-Topic, Spam, or Not Constructive, I am just frustrated to why the code is erroring like this.

1 answer

Log in to vote
2
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
9 years ago

The error is not on your snippet's line 6, but rather on line 7. Concatenate is a word used to describe the combination of strings. Your problem is that you are trying a concatenate a userdata value (A Vector3 in this case).

A work around would be to list the x, y, and z values separately.

local vector3 = Vector3.new(1, 2, 3)

print("Vector3 coordinates are: " .. vector3.x .. ", " .. vector3.y .. ", " .. vector3.z )
-- Output [Vector3 coordinates are: 1, 2, 3]
0
Thanks man! :D It's working perfectly now! :D I didn't know that I had to use the 'X', 'Y', and 'Z' properties to beable to view a 'Vector3' value, as I had never seen using this in another script I've ever viewed. :P Lol, silly me! :P TheeDeathCaster 2368 — 9y
Ad

Answer this question