Local Script cannot detect a vector3 value

For some reason, my script doesnt work, its in a local script, and script.parent does contain that instance, I have never seen anything like this, the instance in case is a vector3 value, It is inside of a tool

local Mouse = game.Players.LocalPlayer:GetMouse()
local Position = Mouse.Hit.Position
script.Parent.gg.Value = Position

If this is a local script, know that no local script will work in the workspace, could you tell me where your script is inside of?

it is inside of a tool inside of the starterpack

I think it has to do something with the “gg” part. Is it unanchored and falling through the map? If not do
‘print(Position)’ to see if the script is actually working.

How on earth can a value fall thru the map?

Its a vector3 value, not a part

Whoops, didn’t see that. You should still try to print the position to make sure the script is running

Can I ask what are you trying to do with this script?

I cant print the position because when i try to it gives me the same error

Im trying to find the position of the mouse so that an object can face it

local players = game:GetService("Players")

local client = players.LocalPlayer
local mouse = client:GetMouse()

local tool = script.Parent
local value = script.Parent.gg

tool.Activated:Connect(function()
	value.Value = mouse.Hit.Position
end)

You can try this script to change the vector3 value whenever you click with the tool.

well, the error persists, “gg is not a valid member of Tool”

If that is the error, you can do

local value = script.Parent:WaitForChild("gg")

That works! the script doesnt work but that part does.

Are you trying to constantly get the mouse vector3?

Yes, I am trying to constantly get it

This code would constantly update the mouse’s vector3 every frame when the tool is equipped

local players = game:GetService("Players")
local runService = game:GetService("RunService")

local client = players.LocalPlayer
local mouse = client:GetMouse()

local tool = script.Parent
local value = script:WaitForChild("Value")

local equipped = false

runService.RenderStepped:Connect(function()
	if equipped then
		value.Value = mouse.Hit.Position
	end
end)

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

There is a problem, it says that because there is infinite yield possible, it doesnt work

Oh sorry, simply change

local value = script:WaitForChild("Value")

to

local value = tool:WaitForChild("gg")

That was my test code

That works! Thanks for that one