Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

trouble changing a Vector3Value inside a character?

local debounce = false
script.Parent.Touched:Connect(function(hit)
	
	local value = hit.Parent:WaitForChild("HomePos")
	
	if hit.Parent:FindFirstChild("Humanoid") and value.Value == Vector3.new(0,0,0) then
		
	if not debounce then debounce = true
		local newpos = script.Parent.Parent.TpPoint
		
		value.Value = Vector3.new(newpos.Position)
	end
	end
end)

Im having trouble setting a vector3 values vector3 using a parts position. there are no errors and if I give it an x,y,z value it works fine but not if I use a parts position. I suspect im using this wrong, but dont be afraid to correct me.

1 answer

✓ Accepted answer

You do not need to construct a new Vector3 value in line 11. The Position property already returns a Vector3.

local debounce = false
script.Parent.Touched:Connect(function(hit)

    local value = hit.Parent:WaitForChild("HomePos")

    if hit.Parent:FindFirstChild("Humanoid") and value.Value == Vector3.new(0,0,0) then

    if not debounce then debounce = true
        local newpos = script.Parent.Parent.TpPoint

        value.Value = newpos.Position
    end
    end
end)

1 comment

0

thanks, I knew it was something small hiding under my nose.

This discussion is preserved as it was. New answers, comments, and votes are closed.